[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CO1PR11MB508965DC03984354CCD5E734D6059@CO1PR11MB5089.namprd11.prod.outlook.com>
Date: Mon, 14 Nov 2022 16:36:30 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Yuan Can <yuancan@...wei.com>,
"Brandeburg, Jesse" <jesse.brandeburg@...el.com>,
"Nguyen, Anthony L" <anthony.l.nguyen@...el.com>,
"davem@...emloft.net" <davem@...emloft.net>,
"edumazet@...gle.com" <edumazet@...gle.com>,
"kuba@...nel.org" <kuba@...nel.org>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"alexander.h.duyck@...el.com" <alexander.h.duyck@...el.com>,
"jeffrey.t.kirsher@...el.com" <jeffrey.t.kirsher@...el.com>,
"Vick, Matthew" <matthew.vick@...el.com>,
"intel-wired-lan@...ts.osuosl.org" <intel-wired-lan@...ts.osuosl.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH 1/2] fm10k: Fix error handling in fm10k_init_module()
> -----Original Message-----
> From: Yuan Can <yuancan@...wei.com>
> Sent: Monday, November 14, 2022 12:27 AM
> To: Brandeburg, Jesse <jesse.brandeburg@...el.com>; Nguyen, Anthony L
> <anthony.l.nguyen@...el.com>; davem@...emloft.net; edumazet@...gle.com;
> kuba@...nel.org; pabeni@...hat.com; alexander.h.duyck@...el.com;
> jeffrey.t.kirsher@...el.com; Vick, Matthew <matthew.vick@...el.com>; Keller,
> Jacob E <jacob.e.keller@...el.com>; intel-wired-lan@...ts.osuosl.org;
> netdev@...r.kernel.org
> Cc: yuancan@...wei.com
> Subject: [PATCH 1/2] fm10k: Fix error handling in fm10k_init_module()
>
> A problem about modprobe fm10k failed is triggered with the following log
> given:
>
> Intel(R) Ethernet Switch Host Interface Driver
> Copyright(c) 2013 - 2019 Intel Corporation.
> debugfs: Directory 'fm10k' with parent '/' already present!
>
> The reason is that fm10k_init_module() returns fm10k_register_pci_driver()
> directly without checking its return value, if fm10k_register_pci_driver()
> failed, it returns without removing debugfs and destroy workqueue,
> resulting the debugfs of fm10k can never be created later and leaks the
> workqueue.
>
> fm10k_init_module()
> alloc_workqueue()
> fm10k_dbg_init() # create debugfs
> fm10k_register_pci_driver()
> pci_register_driver()
> driver_register()
> bus_add_driver()
> priv = kzalloc(...) # OOM happened
> # return without remove debugfs and destroy workqueue
>
> Fix by remove debugfs and destroy workqueue when
> fm10k_register_pci_driver() returns error.
>
> Fixes: 7461fd913afe ("fm10k: Add support for debugfs")
> Fixes: b382bb1b3e2d ("fm10k: use separate workqueue for fm10k driver")
> Signed-off-by: Yuan Can <yuancan@...wei.com>
Makes sense. Thanks!
Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_main.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> index 4a6630586ec9..fc373472e4e1 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
> @@ -32,6 +32,8 @@ struct workqueue_struct *fm10k_workqueue;
> **/
> static int __init fm10k_init_module(void)
> {
> + int ret;
> +
> pr_info("%s\n", fm10k_driver_string);
> pr_info("%s\n", fm10k_copyright);
>
> @@ -43,7 +45,13 @@ static int __init fm10k_init_module(void)
>
> fm10k_dbg_init();
>
> - return fm10k_register_pci_driver();
> + ret = fm10k_register_pci_driver();
> + if (ret) {
> + fm10k_dbg_exit();
> + destroy_workqueue(fm10k_workqueue);
> + }
> +
> + return ret;
> }
> module_init(fm10k_init_module);
>
> --
> 2.17.1
Powered by blists - more mailing lists