Re: [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/19/23 at 09:42am, Andrew Morton wrote:
> On Tue, 19 Sep 2023 12:02:17 +0800 kernel test robot <lkp@xxxxxxxxx> wrote:
> 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head:   7fc7222d9680366edeecc219c21ca96310bdbc10
> > commit: 5c322f6aad10f0920f842a4ccf82e9b9f351c0a5 [5741/5912] crash_core.c: remove unneeded functions
> > config: s390-buildonly-randconfig-r006-20220512 (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@xxxxxxxxx/config)
> > compiler: s390-linux-gcc (GCC) 11.3.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@xxxxxxxxx/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202309191144.B0MToaPG-lkp@xxxxxxxxx/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >    In file included from arch/s390/include/asm/atomic.h:12,
> >                     from include/linux/atomic.h:7,
> >                     from include/linux/mm_types_task.h:13,
> >                     from include/linux/mm_types.h:5,
> >                     from include/linux/buildid.h:5,
> >                     from kernel/crash_core.c:7:
> >    kernel/crash_core.c: In function 'parse_crashkernel_suffix.constprop':
> > >> kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected [-Wnonnull]
> >      214 |         if (strncmp(cur, suffix, strlen(suffix))) {
> >    include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
> >       68 |         (cond) ?                                        \
> >          |          ^~~~
> >    include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
> >       55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> >          |                            ^~~~~~~~~~~~~~
> 
> Looks legit?  parse_crashkernel() does
> 
> 	ret = __parse_crashkernel(cmdline, system_ram, crash_size,
> 				crash_base, NULL);
> 
> and that suffix==NULL gets passed through to the strncmp()?

Yeah, this looks like a false positive report. I reproduced this, below
change can mute the warning. However, the null pointer checking has been
done in __parse_crashkernel() when calls parse_crashkernel_suffix().

Add below check anyway to satisfy the W=1 compiling?

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 1a77d466eaed..b53270ac3715 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -204,6 +204,9 @@ static int __init parse_crashkernel_suffix(char *cmdline,
 {
 	char *cur = cmdline;
 
+	if(!suffix)
+		return -EINVAL;
+
 	*crash_size = memparse(cmdline, &cur);
 	if (cmdline == cur) {
 		pr_warn("crashkernel: memory value expected\n");





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux