From: Dan Carpenter <dan.carpenter@oracle.com>
To: Hangyu Hua <hbh25y@gmail.com>
Cc: manishc@marvell.com, GR-Linux-NIC-Dev@marvell.com,
coiby.xu@gmail.com, gregkh@linuxfoundation.org,
netdev@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: qlge: add unregister_netdev in qlge_probe
Date: Fri, 18 Feb 2022 15:03:44 +0300 [thread overview]
Message-ID: <20220218120344.GH2407@kadam> (raw)
In-Reply-To: <20220218081130.45670-1-hbh25y@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2022-02-18 12:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 8:11 [PATCH] staging: qlge: add unregister_netdev in qlge_probe Hangyu Hua
2022-02-18 12:03 ` Dan Carpenter [this message]
2022-02-21 1:47 ` Hangyu Hua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220218120344.GH2407@kadam \
--to=dan.carpenter@oracle.com \
--cc=GR-Linux-NIC-Dev@marvell.com \
--cc=coiby.xu@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hbh25y@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.