Message ID | 20221206125929.12237-1-zhiguangni01@gmail.com |
---|---|
State | New |
Headers | show |
Series | x86/boot: Check if the input parameter (buffer) of the function is a null pointer | expand |
* Liam Ni <zhiguangni01@gmail.com> wrote: > If the variable buffer is a null pointer, it may cause the kernel to crash. > > Signed-off-by: Liam Ni <zhiguangni01@gmail.com> > --- > arch/x86/boot/cmdline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c > index 21d56ae83cdf..d0809f66054c 100644 > --- a/arch/x86/boot/cmdline.c > +++ b/arch/x86/boot/cmdline.c > @@ -39,7 +39,7 @@ int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *b > st_bufcpy /* Copying this to buffer */ > } state = st_wordstart; > > - if (!cmdline_ptr) > + if (!cmdline_ptr || buffer == NULL) > return -1; /* No command line */ Can this ever happen? Thanks, Ingo
diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c index 21d56ae83cdf..d0809f66054c 100644 --- a/arch/x86/boot/cmdline.c +++ b/arch/x86/boot/cmdline.c @@ -39,7 +39,7 @@ int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *b st_bufcpy /* Copying this to buffer */ } state = st_wordstart; - if (!cmdline_ptr) + if (!cmdline_ptr || buffer == NULL) return -1; /* No command line */ cptr = cmdline_ptr & 0xf;
If the variable buffer is a null pointer, it may cause the kernel to crash. Signed-off-by: Liam Ni <zhiguangni01@gmail.com> --- arch/x86/boot/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)