diff mbox series

[net] fjes: Fix an error handling path in fjes_probe()

Message ID fde673f106d2b264ad76759195901aae94691b5c.1671569785.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [net] fjes: Fix an error handling path in fjes_probe() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
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 success Errors and warnings before: 43 this patch: 43
netdev/cc_maintainers warning 2 maintainers not CCed: u.kleine-koenig@pengutronix.de rafael.j.wysocki@intel.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 41 this patch: 41
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christophe JAILLET Dec. 20, 2022, 8:57 p.m. UTC
A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
by a corresponding netif_napi_del() call in the error handling path of the
probe, as already done inthe remove function.

Fixes: 265859309a76 ("fjes: NAPI polling function")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/fjes/fjes_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michal Swiatkowski Dec. 21, 2022, 9:59 a.m. UTC | #1
On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote:
> A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
> by a corresponding netif_napi_del() call in the error handling path of the
> probe, as already done inthe remove function.
> 
> Fixes: 265859309a76 ("fjes: NAPI polling function")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/net/fjes/fjes_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
> index 2513be6d4e11..01b4c9c6adbd 100644
> --- a/drivers/net/fjes/fjes_main.c
> +++ b/drivers/net/fjes/fjes_main.c
> @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev)
>  	adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
>  	if (unlikely(!adapter->txrx_wq)) {
>  		err = -ENOMEM;
> -		goto err_free_netdev;
> +		goto err_del_napi;
>  	}
>  
>  	adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
> @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev)
>  	destroy_workqueue(adapter->control_wq);
>  err_free_txrx_wq:
>  	destroy_workqueue(adapter->txrx_wq);
> +err_del_napi:
> +	netif_napi_del(&adapter->napi);
>  err_free_netdev:
>  	free_netdev(netdev);
>  err_out:

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

I wonder if it won't be better to have fjes_sw_deinit() instead or
change fjes_sw_init to only netif_napi_add(). You know, to avoid another
bug here when someone add sth to the fjes_sw_deinit(). This is only
suggestion, patch looks fine.

> -- 
> 2.34.1
>
Jakub Kicinski Dec. 22, 2022, 1:40 a.m. UTC | #2
On Tue, 20 Dec 2022 21:57:06 +0100 Christophe JAILLET wrote:
> A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
> by a corresponding netif_napi_del() call in the error handling path of the
> probe, as already done inthe remove function.

Ah, now I see why Michal asked about netif_napi_del() in the other
driver :S  free_netdev() cleans up NAPIs.
Christophe JAILLET Dec. 29, 2022, 4:34 p.m. UTC | #3
Le 21/12/2022 à 10:59, Michal Swiatkowski a écrit :
> On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote:
>> A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
>> by a corresponding netif_napi_del() call in the error handling path of the
>> probe, as already done inthe remove function.
>>
>> Fixes: 265859309a76 ("fjes: NAPI polling function")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/net/fjes/fjes_main.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
>> index 2513be6d4e11..01b4c9c6adbd 100644
>> --- a/drivers/net/fjes/fjes_main.c
>> +++ b/drivers/net/fjes/fjes_main.c
>> @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev)
>>   	adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
>>   	if (unlikely(!adapter->txrx_wq)) {
>>   		err = -ENOMEM;
>> -		goto err_free_netdev;
>> +		goto err_del_napi;
>>   	}
>>   
>>   	adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
>> @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev)
>>   	destroy_workqueue(adapter->control_wq);
>>   err_free_txrx_wq:
>>   	destroy_workqueue(adapter->txrx_wq);
>> +err_del_napi:
>> +	netif_napi_del(&adapter->napi);
>>   err_free_netdev:
>>   	free_netdev(netdev);
>>   err_out:
> 
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> 
> I wonder if it won't be better to have fjes_sw_deinit() instead or
> change fjes_sw_init to only netif_napi_add(). You know, to avoid another
> bug here when someone add sth to the fjes_sw_deinit(). This is only
> suggestion, patch looks fine.

hi,

based on Jakub's comment [1], free_netdev() already cleans up NAPIs (see 
[2]).

So would it make more sense to remove netif_napi_del() from the 
.remove() function instead?
The call looks useless to me now.

CJ

[1]: https://lore.kernel.org/all/20221221174043.1191996a@kernel.org/
[2]: https://elixir.bootlin.com/linux/v6.2-rc1/source/net/core/dev.c#L10710

> 
>> -- 
>> 2.34.1
>>
>
Michal Swiatkowski Jan. 4, 2023, 11:24 a.m. UTC | #4
On Thu, Dec 29, 2022 at 05:34:22PM +0100, Christophe JAILLET wrote:
> Le 21/12/2022 à 10:59, Michal Swiatkowski a écrit :
> > On Tue, Dec 20, 2022 at 09:57:06PM +0100, Christophe JAILLET wrote:
> > > A netif_napi_add() call is hidden in fjes_sw_init(). It should be undone
> > > by a corresponding netif_napi_del() call in the error handling path of the
> > > probe, as already done inthe remove function.
> > > 
> > > Fixes: 265859309a76 ("fjes: NAPI polling function")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > ---
> > >   drivers/net/fjes/fjes_main.c | 4 +++-
> > >   1 file changed, 3 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
> > > index 2513be6d4e11..01b4c9c6adbd 100644
> > > --- a/drivers/net/fjes/fjes_main.c
> > > +++ b/drivers/net/fjes/fjes_main.c
> > > @@ -1370,7 +1370,7 @@ static int fjes_probe(struct platform_device *plat_dev)
> > >   	adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
> > >   	if (unlikely(!adapter->txrx_wq)) {
> > >   		err = -ENOMEM;
> > > -		goto err_free_netdev;
> > > +		goto err_del_napi;
> > >   	}
> > >   	adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
> > > @@ -1431,6 +1431,8 @@ static int fjes_probe(struct platform_device *plat_dev)
> > >   	destroy_workqueue(adapter->control_wq);
> > >   err_free_txrx_wq:
> > >   	destroy_workqueue(adapter->txrx_wq);
> > > +err_del_napi:
> > > +	netif_napi_del(&adapter->napi);
> > >   err_free_netdev:
> > >   	free_netdev(netdev);
> > >   err_out:
> > 
> > Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> > 
> > I wonder if it won't be better to have fjes_sw_deinit() instead or
> > change fjes_sw_init to only netif_napi_add(). You know, to avoid another
> > bug here when someone add sth to the fjes_sw_deinit(). This is only
> > suggestion, patch looks fine.
> 
> hi,
> 
> based on Jakub's comment [1], free_netdev() already cleans up NAPIs (see
> [2]).
> 
> So would it make more sense to remove netif_napi_del() from the .remove()
> function instead?
> The call looks useless to me now.
> 
> CJ
> 
> [1]: https://lore.kernel.org/all/20221221174043.1191996a@kernel.org/
> [2]: https://elixir.bootlin.com/linux/v6.2-rc1/source/net/core/dev.c#L10710
> 

Yeah, it make more sense.

Thanks, Michal
> > 
> > > -- 
> > > 2.34.1
> > > 
> > 
>
diff mbox series

Patch

diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
index 2513be6d4e11..01b4c9c6adbd 100644
--- a/drivers/net/fjes/fjes_main.c
+++ b/drivers/net/fjes/fjes_main.c
@@ -1370,7 +1370,7 @@  static int fjes_probe(struct platform_device *plat_dev)
 	adapter->txrx_wq = alloc_workqueue(DRV_NAME "/txrx", WQ_MEM_RECLAIM, 0);
 	if (unlikely(!adapter->txrx_wq)) {
 		err = -ENOMEM;
-		goto err_free_netdev;
+		goto err_del_napi;
 	}
 
 	adapter->control_wq = alloc_workqueue(DRV_NAME "/control",
@@ -1431,6 +1431,8 @@  static int fjes_probe(struct platform_device *plat_dev)
 	destroy_workqueue(adapter->control_wq);
 err_free_txrx_wq:
 	destroy_workqueue(adapter->txrx_wq);
+err_del_napi:
+	netif_napi_del(&adapter->napi);
 err_free_netdev:
 	free_netdev(netdev);
 err_out: