[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a8d5b618-f5ee-686e-d614-dd038004d488@gmail.com>
Date: Mon, 21 Feb 2022 09:47:09 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: manishc@...vell.com, GR-Linux-NIC-Dev@...vell.com,
coiby.xu@...il.com, gregkh@...uxfoundation.org,
netdev@...r.kernel.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: qlge: add unregister_netdev in qlge_probe
Thanks for your suggesion. I will resubmit later.
On 2022/2/18 20:03, Dan Carpenter wrote:
> On Fri, Feb 18, 2022 at 04:11:30PM +0800, Hangyu Hua wrote:
>> unregister_netdev need to be called when register_netdev succeeds
>> qlge_health_create_reporters fails.
>>
>
> 1) Add a Fixes tag:
>
> Fixes: d8827ae8e22b ("staging: qlge: deal with the case that devlink_health_reporter_create fails")
>
>> Signed-off-by: Hangyu Hua <hbh25y@...il.com>
>> ---
>> drivers/staging/qlge/qlge_main.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
>> index 9873bb2a9ee4..0a199c6d77a1 100644
>> --- a/drivers/staging/qlge/qlge_main.c
>> +++ b/drivers/staging/qlge/qlge_main.c
>> @@ -4611,8 +4611,10 @@ static int qlge_probe(struct pci_dev *pdev,
>> }
>>
>> err = qlge_health_create_reporters(qdev);
>> - if (err)
>> + if (err) {
>> + unregister_netdev(ndev);
>> goto netdev_free;
>> + }
>
> 2) Use a goto to unwind. 3) Release the other pdev stuff as well.
> 4) Clean up the error handling for register_netdev() by using a goto
> as well.
>
> err = register_netdev(ndev);
> if (err) {
> dev_err(&pdev->dev, "net device registration failed.\n");
> goto cleanup_pdev;
> }
>
> err = qlge_health_create_reporters(qdev);
> if (err)
> goto unregister_netdev;
>
> ...
>
> return 0;
>
> unregister_netdev:
> unregister_netdev(ndev);
> cleanup_pdev:
> qlge_release_all(pdev);
> pci_disable_device(pdev);
> netdev_free:
> free_netdev(ndev);
> devlink_free:
> devlink_free(devlink);
>
> return ret;
>
> regards,
> dan carpenter
>
Powered by blists - more mailing lists