diff mbox series

dpaa2-eth: add error handling code for dpaa2_eth_dl_register

Message ID 20211130042021.869529-1-mudongliangabcd@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series dpaa2-eth: add error handling code for dpaa2_eth_dl_register | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 0 this patch: 8
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang fail Errors and warnings before: 0 this patch: 9
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dongliang Mu Nov. 30, 2021, 4:20 a.m. UTC
The commit bbb9ae25fc67 ("dpaa2-eth: Register devlink instance at the end
of probe") moves dpaa2_eth_dl_register at the end of dpaa2_eth_probe.
However, dpaa2_eth_dl_register can return errno when memory allocation or
devlink_register fails.

Fix this by adding error handling code for dpaa2_eth_dl_register

Fixes: bbb9ae25fc67 ("dpaa2-eth: Register devlink instance at the end of probe")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

kernel test robot Dec. 1, 2021, 12:04 p.m. UTC | #1
Hi Dongliang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.16-rc3 next-20211201]
[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]

url:    https://github.com/0day-ci/linux/commits/Dongliang-Mu/dpaa2-eth-add-error-handling-code-for-dpaa2_eth_dl_register/20211130-122101
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d58071a8a76d779eedab38033ae4c821c30295a5
config: arm64-defconfig (https://download.01.org/0day-ci/archive/20211201/202112012029.0sSjB1Bn-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 11.2.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/0day-ci/linux/commit/8c2f20e67d1f8605b042655d121a18f5ce61faa7
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Dongliang-Mu/dpaa2-eth-add-error-handling-code-for-dpaa2_eth_dl_register/20211130-122101
        git checkout 8c2f20e67d1f8605b042655d121a18f5ce61faa7
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c: In function 'dpaa2_eth_probe':
>> drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:4465:13: error: void value not ignored as it ought to be
    4465 |         err = dpaa2_eth_dl_register(priv);
         |             ^


vim +4465 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

  4464	
> 4465		err = dpaa2_eth_dl_register(priv);
  4466		if (err < 0) {
  4467			dev_err(dev, "dpaa2_eth_dl_register failed\n");
  4468			goto err_dl_register;
  4469		}
  4470		dev_info(dev, "Probed interface %s\n", net_dev->name);
  4471		return 0;
  4472	
  4473	err_dl_register:
  4474	#ifdef CONFIG_DEBUG_FS
  4475		dpaa2_dbg_remove(priv);
  4476	#endif
  4477		unregister_netdev(net_dev);
  4478	err_netdev_reg:
  4479		dpaa2_eth_dl_port_del(priv);
  4480	err_dl_port_add:
  4481		dpaa2_eth_dl_traps_unregister(priv);
  4482	err_dl_trap_register:
  4483		dpaa2_eth_dl_free(priv);
  4484	err_dl_alloc:
  4485		dpaa2_eth_disconnect_mac(priv);
  4486	err_connect_mac:
  4487		if (priv->do_link_poll)
  4488			kthread_stop(priv->poll_thread);
  4489		else
  4490			fsl_mc_free_irqs(dpni_dev);
  4491	err_poll_thread:
  4492		dpaa2_eth_free_rings(priv);
  4493	err_alloc_rings:
  4494	err_csum:
  4495	err_netdev_init:
  4496		free_percpu(priv->sgt_cache);
  4497	err_alloc_sgt_cache:
  4498		free_percpu(priv->percpu_extras);
  4499	err_alloc_percpu_extras:
  4500		free_percpu(priv->percpu_stats);
  4501	err_alloc_percpu_stats:
  4502		dpaa2_eth_del_ch_napi(priv);
  4503	err_bind:
  4504		dpaa2_eth_free_dpbp(priv);
  4505	err_dpbp_setup:
  4506		dpaa2_eth_free_dpio(priv);
  4507	err_dpio_setup:
  4508		dpaa2_eth_free_dpni(priv);
  4509	err_dpni_setup:
  4510		fsl_mc_portal_free(priv->mc_io);
  4511	err_portal_alloc:
  4512		destroy_workqueue(priv->dpaa2_ptp_wq);
  4513	err_wq_alloc:
  4514		dev_set_drvdata(dev, NULL);
  4515		free_netdev(net_dev);
  4516	
  4517		return err;
  4518	}
  4519	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Dongliang Mu Dec. 1, 2021, 12:24 p.m. UTC | #2
On Wed, Dec 1, 2021 at 8:04 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Dongliang,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on linus/master]
> [also build test ERROR on v5.16-rc3 next-20211201]
> [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]
>
> url:    https://github.com/0day-ci/linux/commits/Dongliang-Mu/dpaa2-eth-add-error-handling-code-for-dpaa2_eth_dl_register/20211130-122101
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git d58071a8a76d779eedab38033ae4c821c30295a5
> config: arm64-defconfig (https://download.01.org/0day-ci/archive/20211201/202112012029.0sSjB1Bn-lkp@intel.com/config)
> compiler: aarch64-linux-gcc (GCC) 11.2.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/0day-ci/linux/commit/8c2f20e67d1f8605b042655d121a18f5ce61faa7
>         git remote add linux-review https://github.com/0day-ci/linux
>         git fetch --no-tags linux-review Dongliang-Mu/dpaa2-eth-add-error-handling-code-for-dpaa2_eth_dl_register/20211130-122101
>         git checkout 8c2f20e67d1f8605b042655d121a18f5ce61faa7
>         # save the config file to linux build tree
>         mkdir build_dir
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/net/
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>    drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c: In function 'dpaa2_eth_probe':
> >> drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c:4465:13: error: void value not ignored as it ought to be
>     4465 |         err = dpaa2_eth_dl_register(priv);
>          |             ^
>

Hi all,

please ignore my stupid patch.

>
> vim +4465 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
>
>   4464
> > 4465          err = dpaa2_eth_dl_register(priv);
>   4466          if (err < 0) {
>   4467                  dev_err(dev, "dpaa2_eth_dl_register failed\n");
>   4468                  goto err_dl_register;
>   4469          }
>   4470          dev_info(dev, "Probed interface %s\n", net_dev->name);
>   4471          return 0;
>   4472
>   4473  err_dl_register:
>   4474  #ifdef CONFIG_DEBUG_FS
>   4475          dpaa2_dbg_remove(priv);
>   4476  #endif
>   4477          unregister_netdev(net_dev);
>   4478  err_netdev_reg:
>   4479          dpaa2_eth_dl_port_del(priv);
>   4480  err_dl_port_add:
>   4481          dpaa2_eth_dl_traps_unregister(priv);
>   4482  err_dl_trap_register:
>   4483          dpaa2_eth_dl_free(priv);
>   4484  err_dl_alloc:
>   4485          dpaa2_eth_disconnect_mac(priv);
>   4486  err_connect_mac:
>   4487          if (priv->do_link_poll)
>   4488                  kthread_stop(priv->poll_thread);
>   4489          else
>   4490                  fsl_mc_free_irqs(dpni_dev);
>   4491  err_poll_thread:
>   4492          dpaa2_eth_free_rings(priv);
>   4493  err_alloc_rings:
>   4494  err_csum:
>   4495  err_netdev_init:
>   4496          free_percpu(priv->sgt_cache);
>   4497  err_alloc_sgt_cache:
>   4498          free_percpu(priv->percpu_extras);
>   4499  err_alloc_percpu_extras:
>   4500          free_percpu(priv->percpu_stats);
>   4501  err_alloc_percpu_stats:
>   4502          dpaa2_eth_del_ch_napi(priv);
>   4503  err_bind:
>   4504          dpaa2_eth_free_dpbp(priv);
>   4505  err_dpbp_setup:
>   4506          dpaa2_eth_free_dpio(priv);
>   4507  err_dpio_setup:
>   4508          dpaa2_eth_free_dpni(priv);
>   4509  err_dpni_setup:
>   4510          fsl_mc_portal_free(priv->mc_io);
>   4511  err_portal_alloc:
>   4512          destroy_workqueue(priv->dpaa2_ptp_wq);
>   4513  err_wq_alloc:
>   4514          dev_set_drvdata(dev, NULL);
>   4515          free_netdev(net_dev);
>   4516
>   4517          return err;
>   4518  }
>   4519
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 6451c8383639..4bb2b838fa50 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -4442,7 +4442,7 @@  static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
 
 	err = dpaa2_eth_dl_alloc(priv);
 	if (err)
-		goto err_dl_register;
+		goto err_dl_alloc;
 
 	err = dpaa2_eth_dl_traps_register(priv);
 	if (err)
@@ -4462,17 +4462,26 @@  static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
 	dpaa2_dbg_add(priv);
 #endif
 
-	dpaa2_eth_dl_register(priv);
+	err = dpaa2_eth_dl_register(priv);
+	if (err < 0) {
+		dev_err(dev, "dpaa2_eth_dl_register failed\n");
+		goto err_dl_register;
+	}
 	dev_info(dev, "Probed interface %s\n", net_dev->name);
 	return 0;
 
+err_dl_register:
+#ifdef CONFIG_DEBUG_FS
+	dpaa2_dbg_remove(priv);
+#endif
+	unregister_netdev(net_dev);
 err_netdev_reg:
 	dpaa2_eth_dl_port_del(priv);
 err_dl_port_add:
 	dpaa2_eth_dl_traps_unregister(priv);
 err_dl_trap_register:
 	dpaa2_eth_dl_free(priv);
-err_dl_register:
+err_dl_alloc:
 	dpaa2_eth_disconnect_mac(priv);
 err_connect_mac:
 	if (priv->do_link_poll)