lkml.org 
[lkml]   [2021]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] um: ubd: Fix crash from option parsing
Date
Paul Lawrence <paullawrence@google.com> writes:

> Below patch will cause NULL ptr dereferences if the optional filenames
> are not present.
>
> Fixes: ef3ba87cb7c9 (um: ubd: Set device serial attribute from cmdline)
> Signed-off-by: Paul Lawrence <paullawrence@google.com>

Looks good.

Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>

Totally unrelated, but it seems the original patch writes a "(null)"
string to the sysfs attribute, if no serial is defined. I think we
should have a default serial UBDX in case the user didn't provide any.

Thanks,

> ---
> arch/um/drivers/ubd_kern.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
> index 13b1fe694b90..704989088f28 100644
> --- a/arch/um/drivers/ubd_kern.c
> +++ b/arch/um/drivers/ubd_kern.c
> @@ -371,15 +371,15 @@ static int ubd_setup_common(char *str, int *index_out, char **error_out)
>
> break_loop:
> file = strsep(&str, ",:");
> - if (*file == '\0')
> + if (file && *file == '\0')
> 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) {

--
Gabriel Krisman Bertazi

\
 
 \ /
  Last update: 2021-01-19 19:44    [W:0.064 / U:0.340 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site