]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
arm64: kexec_file: handle empty command-line
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Fri, 1 Feb 2019 16:26:08 +0000 (16:26 +0000)
committerWill Deacon <will.deacon@arm.com>
Tue, 5 Feb 2019 09:34:49 +0000 (09:34 +0000)
Calling strlen() on cmdline == NULL produces a kernel oops. Since having
a NULL cmdline is valid, handle this case explicitly.

Fixes: 52b2a8af7436 ("arm64: kexec_file: load initrd and device-tree")
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/machine_kexec_file.c

index f2c211a6229baa3928ba4a652e9c4a947fe27dae..58871333737a4e5458d723dcb0fd6e5e609548da 100644 (file)
@@ -120,10 +120,12 @@ static int create_dtb(struct kimage *image,
 {
        void *buf;
        size_t buf_size;
+       size_t cmdline_len;
        int ret;
 
+       cmdline_len = cmdline ? strlen(cmdline) : 0;
        buf_size = fdt_totalsize(initial_boot_params)
-                       + strlen(cmdline) + DTB_EXTRA_SPACE;
+                       + cmdline_len + DTB_EXTRA_SPACE;
 
        for (;;) {
                buf = vmalloc(buf_size);