Message ID | 20221113093719.23687-2-yuancan@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Fix error handling path | expand |
Hi Yuan, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on net-next/master] [also build test WARNING on net/master linus/master v6.1-rc4 next-20221111] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Yuan-Can/Fix-error-handling-path/20221113-174019 patch link: https://lore.kernel.org/r/20221113093719.23687-2-yuancan%40huawei.com patch subject: [PATCH 1/2] net: skge: Fix error handling in skge_init_module() config: openrisc-buildonly-randconfig-r003-20221113 compiler: or1k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/d0e0ff74baf3e1336c052f8100f16f21b80b43a6 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Yuan-Can/Fix-error-handling-path/20221113-174019 git checkout d0e0ff74baf3e1336c052f8100f16f21b80b43a6 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc SHELL=/bin/bash drivers/net/ethernet/marvell/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/net/ethernet/marvell/skge.c: In function 'skge_init_module': >> drivers/net/ethernet/marvell/skge.c:4189:37: warning: suggest braces around empty body in an 'if' statement [-Wempty-body] 4189 | skge_debug_cleanup(); | ^ vim +/if +4189 drivers/net/ethernet/marvell/skge.c 4179 4180 static int __init skge_init_module(void) 4181 { 4182 int ret; 4183 4184 if (dmi_check_system(skge_32bit_dma_boards)) 4185 only_32bit_dma = 1; 4186 skge_debug_init(); 4187 ret = pci_register_driver(&skge_driver); 4188 if (ret) > 4189 skge_debug_cleanup(); 4190 4191 return ret; 4192 } 4193
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c index 1b43704baceb..01d141369b3e 100644 --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c @@ -3776,7 +3776,7 @@ static __init void skge_debug_init(void) register_netdevice_notifier(&skge_notifier); } -static __exit void skge_debug_cleanup(void) +static void skge_debug_cleanup(void) { if (skge_debug) { unregister_netdevice_notifier(&skge_notifier); @@ -4179,10 +4179,16 @@ static const struct dmi_system_id skge_32bit_dma_boards[] = { static int __init skge_init_module(void) { + int ret; + if (dmi_check_system(skge_32bit_dma_boards)) only_32bit_dma = 1; skge_debug_init(); - return pci_register_driver(&skge_driver); + ret = pci_register_driver(&skge_driver); + if (ret) + skge_debug_cleanup(); + + return ret; } static void __exit skge_cleanup_module(void)
A problem about modprobe skge failed is triggered with the following log given: debugfs: Directory 'skge' with parent '/' already present! ------------[ cut here ]------------ notifier callback skge_device_event [skge] already registered WARNING: CPU: 1 PID: 236 at kernel/notifier.c:29 notifier_chain_register+0x168/0x230 ... The reason is that skge_init_module() returns pci_register_driver() directly without checking its return value, if pci_register_driver() failed, it returns without removing skge debugfs and unregister skge_notifier, resulting the debugfs of skge can never be created later and triggers the WARNING of notifier registered. skge_init_module() skge_debug_init() # create debugfs and register skge_notifier pci_register_driver() driver_register() bus_add_driver() priv = kzalloc(...) # OOM happened # return without destroy debugfs and unregister skge_notifier Fix by calling skge_debug_cleanup() when pci_register_driver() returns error. Fixes: 678aa1f6ac86 ("skge: add a debug interface") Signed-off-by: Yuan Can <yuancan@huawei.com> --- drivers/net/ethernet/marvell/skge.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)