Skip to content

Commit ea57368

Browse files
Jean-Philippe Bruckerwildea01
authored andcommitted
arm64: kexec_file: handle empty command-line
Calling strlen() on cmdline == NULL produces a kernel oops. Since having a NULL cmdline is valid, handle this case explicitly. Fixes: 52b2a8a ("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>
1 parent d23c808 commit ea57368

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/arm64/kernel/machine_kexec_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ static int create_dtb(struct kimage *image,
120120
{
121121
void *buf;
122122
size_t buf_size;
123+
size_t cmdline_len;
123124
int ret;
124125

126+
cmdline_len = cmdline ? strlen(cmdline) : 0;
125127
buf_size = fdt_totalsize(initial_boot_params)
126-
+ strlen(cmdline) + DTB_EXTRA_SPACE;
128+
+ cmdline_len + DTB_EXTRA_SPACE;
127129

128130
for (;;) {
129131
buf = vmalloc(buf_size);

0 commit comments

Comments
 (0)