kernel/printk/printk.c:2468 __alloc_atomic_data() warn: returning -1 instead of -ENOMEM is sloppy
PATCH 21/51 kernel/printk/printk.c:2468 __alloc_atomic_data() warn: returning -1 instead of -ENOMEM is sloppy
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-6.1.y-rt-rebase head: 90d96fee668dc306dd748393383c0fc74b798eee commit: cf8dd889ea20ae7091d3b27029b07bef13298291 [21/51] serial: 8250: implement write_atomic config: i386-randconfig-141-20230828 (https://download.01.org/0day-ci/archive/20230828/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230828/[email protected]/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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:kernel/printk/printk.c:2468 __alloc_atomic_data() warn: returning -1 instead of -ENOMEM is sloppy
vim +2468 kernel/printk/printk.c
09cbc4e64a7546 John Ogness 2022-02-04 2464 static int __alloc_atomic_data(struct console_atomic_data *d, short flags)
09cbc4e64a7546 John Ogness 2022-02-04 2465 {
09cbc4e64a7546 John Ogness 2022-02-04 2466 d->text = kmalloc(CONSOLE_LOG_MAX, GFP_KERNEL);
09cbc4e64a7546 John Ogness 2022-02-04 2467 if (!d->text)
09cbc4e64a7546 John Ogness 2022-02-04 @2468 return -1;Just return -ENOMEM. Even if it doesn't get passed back to the user, it's just better to do things in a normal way.
09cbc4e64a7546 John Ogness 2022-02-04 2469
09cbc4e64a7546 John Ogness 2022-02-04 2470 if (flags & CON_EXTENDED) {
09cbc4e64a7546 John Ogness 2022-02-04 2471 d->ext_text = kmalloc(CONSOLE_EXT_LOG_MAX, GFP_KERNEL);
09cbc4e64a7546 John Ogness 2022-02-04 2472 if (!d->ext_text)
09cbc4e64a7546 John Ogness 2022-02-04 2473 return -1;
09cbc4e64a7546 John Ogness 2022-02-04 2474 } else {
09cbc4e64a7546 John Ogness 2022-02-04 2475 d->dropped_text = kmalloc(DROPPED_TEXT_MAX, GFP_KERNEL);
09cbc4e64a7546 John Ogness 2022-02-04 2476 if (!d->dropped_text)
09cbc4e64a7546 John Ogness 2022-02-04 2477 return -1;
09cbc4e64a7546 John Ogness 2022-02-04 2478 }
09cbc4e64a7546 John Ogness 2022-02-04 2479
09cbc4e64a7546 John Ogness 2022-02-04 2480 return 0;
09cbc4e64a7546 John Ogness 2022-02-04 2481 }Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 5 lines · Dan Carpenter
smatch warnings:
kernel/printk/printk.c:2468__alloc_atomic_data()warn: returning -1 instead of-ENOMEMis sloppyvim +2468
kernel/printk/printk.c
Quoted 8 lines
09cbc4e64a7546 John Ogness 2022-02-04 2464 static int __alloc_atomic_data(struct console_atomic_data *d, short flags) 09cbc4e64a7546 John Ogness 2022-02-04 2465 { 09cbc4e64a7546 John Ogness 2022-02-04 2466 d->text = kmalloc(CONSOLE_LOG_MAX, GFP_KERNEL); 09cbc4e64a7546 John Ogness 2022-02-04 2467 if (!d->text) 09cbc4e64a7546 John Ogness 2022-02-04 @2468 return -1;Just return
-ENOMEM. Even if it doesn't get passed back to the user, it's just better to do things in a normal way.
John, are you going to integrate this or did you rewrite the code to the point that it has been "fixed"?
Sebastian
Quoted 6 lines · Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-6.1.y-rt-rebase head: 90d96fee668dc306dd748393383c0fc74b798eee commit: cf8dd889ea20ae7091d3b27029b07bef13298291 [21/51] serial: 8250: implement write_atomic config: i386-randconfig-141-20230828 (https://download.01.org/0day-ci/archive/20230828/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230828/[email protected]/reproduce)
Now that I looked again at it. The 6.1 is outdated and no longer updated. The -1 vs -ENOMEM is not present in the v6.5 series which current so I can't fix it there…
The 6.1 tree itself is stable maintained. If you want this fixed in the stable tree for 6.1
https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
and I assume it is there, then I would send Clark a patch…
Sebastian
Quoted 12 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Dan Carpenter
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-6.1.y-rt-rebase head: 90d96fee668dc306dd748393383c0fc74b798eee commit: cf8dd889ea20ae7091d3b27029b07bef13298291 [21/51] serial: 8250: implement write_atomic config: i386-randconfig-141-20230828 (https://download.01.org/0day-ci/archive/20230828/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230828/[email protected]/reproduce)Now that I looked again at it. The 6.1 is outdated and no longer updated. The -1 vs
-ENOMEMis not present in the v6.5 series which current so I can't fix it there…
Quoted 5 lines
The 6.1 tree itself is stable maintained. If you want this fixed in the stable tree for 6.1
https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.gitand I assume it is there, then I would send Clark a patch…
Forget about it. This doesn't matter at all. I thought since kbuild was reporting it then the code was new. Sorry for the noise.
regards,
dan carpenter
Quoted 2 lines · Dan Carpenter
Forget about it. This doesn't matter at all. I thought since kbuild was reporting it then the code was new. Sorry for the noise.
Okay, no worries.
If you find something in the for-kbuild-bot/current-stable branch I'm all yours.
Quoted 2 lines
regards,
dan carpenter
Sebastian