um: ubd: fix command line handling of ubd
authorHajime Tazaki <thehajime@gmail.com>
Mon, 21 Dec 2020 02:24:34 +0000 (11:24 +0900)
committerRichard Weinberger <richard@nod.at>
Tue, 26 Jan 2021 21:10:44 +0000 (22:10 +0100)
This commit fixes a regression to handle command line parameters of ubd.
With a simple line "./linux ubd0="./disk-ext4.img", it fails at
ubd_setup_common().  The commit adds additional checks to the variables
in order to properly parse the paremeters which previously worked.

Fixes: ef3ba87cb7c9 ("um: ubd: Set device serial attribute from cmdline")
Cc: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
Acked-by: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/drivers/ubd_kern.c

index 13b1fe6..bd16b17 100644 (file)
@@ -375,11 +375,11 @@ break_loop:
                file = NULL;
 
        backing_file = strsep(&str, ",:");
-       if (*backing_file == '\0')
+       if (backing_file && *backing_file == '\0')
                backing_file = NULL;
 
        serial = strsep(&str, ",:");
-       if (*serial == '\0')
+       if (serial && *serial == '\0')
                serial = NULL;
 
        if (backing_file && ubd_dev->no_cow) {