From: Michael Brown Date: Mon, 28 Apr 2025 22:54:01 +0000 (+0100) Subject: [prefix] Remove userptr_t from command line image construction X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=43fc516298273d12099da4fcd2cc7c0af0a1ea86;p=thirdparty%2Fipxe.git [prefix] Remove userptr_t from command line image construction Simplify cmdline_init() by assuming that the externally provided command line is directly accessible via pointer dereferences. Signed-off-by: Michael Brown --- diff --git a/src/arch/x86/core/runtime.c b/src/arch/x86/core/runtime.c index 2d2a10674..1fdf80497 100644 --- a/src/arch/x86/core/runtime.c +++ b/src/arch/x86/core/runtime.c @@ -114,9 +114,7 @@ static void cmdline_strip ( char *cmdline, const char *cruft ) { * @ret rc Return status code */ static int cmdline_init ( void ) { - userptr_t cmdline_user; char *cmdline; - size_t len; int rc; /* Do nothing if no command line was specified */ @@ -124,19 +122,15 @@ static int cmdline_init ( void ) { DBGC ( colour, "RUNTIME found no command line\n" ); return 0; } - cmdline_user = phys_to_virt ( cmdline_phys ); - len = ( strlen ( cmdline_user ) + 1 /* NUL */ ); /* Allocate and copy command line */ - cmdline_copy = malloc ( len ); + cmdline_copy = strdup ( phys_to_virt ( cmdline_phys ) ); if ( ! cmdline_copy ) { - DBGC ( colour, "RUNTIME could not allocate %zd bytes for " - "command line\n", len ); + DBGC ( colour, "RUNTIME could not allocate command line\n" ); rc = -ENOMEM; goto err_alloc_cmdline_copy; } cmdline = cmdline_copy; - copy_from_user ( cmdline, cmdline_user, 0, len ); DBGC ( colour, "RUNTIME found command line \"%s\" at %08x\n", cmdline, cmdline_phys ); @@ -151,7 +145,7 @@ static int cmdline_init ( void ) { DBGC ( colour, "RUNTIME using command line \"%s\"\n", cmdline ); /* Prepare and register image */ - cmdline_image.data = virt_to_user ( cmdline ); + cmdline_image.data = cmdline; cmdline_image.len = strlen ( cmdline ); if ( cmdline_image.len ) { if ( ( rc = register_image ( &cmdline_image ) ) != 0 ) {