From: Wojciech Drewek <wojciech.drewek@intel.com>
To: Markus Elfring <Markus.Elfring@web.de>,
Julia Lawall <Julia.Lawall@inria.fr>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Jakub Kicinski <kuba@kernel.org>,
"Justin Chen" <justin.chen@broadcom.com>,
Paolo Abeni <pabeni@redhat.com>,
<bcm-kernel-feedback-list@broadcom.com>, <netdev@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Cc: <cocci@inria.fr>, LKML <linux-kernel@vger.kernel.org>,
Simon Horman <horms@kernel.org>
Subject: Re: [PATCH] net: bcmasp: Use common error handling code in bcmasp_probe()
Date: Mon, 6 Nov 2023 15:24:16 +0100 [thread overview]
Message-ID: <5e2b91e2-91a9-4b7e-a196-ae5b4a082490@intel.com> (raw)
In-Reply-To: <2b5e219a-85dc-4347-b5d0-86059181be93@web.de>
On 06.11.2023 14:55, Markus Elfring wrote:
> …
>>> Add a jump target so that a bit of exception handling can be better
>>> reused at the end of this function.
> …
>>> +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
>>> @@ -1304,9 +1304,8 @@ static int bcmasp_probe(struct platform_device *pdev)
>>> intf = bcmasp_interface_create(priv, intf_node, i);
>>> if (!intf) {
>>> dev_err(dev, "Cannot create eth interface %d\n", i);
>>> - bcmasp_remove_intfs(priv);
>>> of_node_put(intf_node);
>>> - goto of_put_exit;
>>> + goto remove_intfs;
>>> }
>>> list_add_tail(&intf->list, &priv->intfs);
>>> i++;
>>> @@ -1331,8 +1330,7 @@ static int bcmasp_probe(struct platform_device *pdev)
>>> netdev_err(intf->ndev,
>>> "failed to register net_device: %d\n", ret);
>>> priv->destroy_wol(priv);
>>> - bcmasp_remove_intfs(priv);
>>> - goto of_put_exit;
>>> + goto remove_intfs;
>>> }
>>> count++;
>>> }
>>> @@ -1342,6 +1340,10 @@ static int bcmasp_probe(struct platform_device *pdev)
>>> of_put_exit:
>>> of_node_put(ports_node);
>>> return ret;
>>> +
>>> +remove_intfs:
>>> + bcmasp_remove_intfs(priv);
>>> + goto of_put_exit;
>>
>> Why is it at the end of the function? Just move it above of_put_exit and it will naturally
>> go to the of_node_put call. No need for "goto of_put_exit".
>
> I got the impression that the call of the function “bcmasp_remove_intfs” belongs only
> to exceptional cases in the shown control flow.
Ah, yes, you're right. If we move it above of_put_exit as I suggested then it'll be
executed in successful path as well.
Makes sense now
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
>
> Regards,
> Markus
next prev parent reply other threads:[~2023-11-06 14:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0b2972cb-03b2-40c7-a728-6ebe2512637f@web.de>
2023-11-06 10:02 ` Wojciech Drewek
[not found] ` <2b5e219a-85dc-4347-b5d0-86059181be93@web.de>
2023-11-06 14:24 ` Wojciech Drewek [this message]
2023-11-06 22:58 ` Jakub Kicinski
[not found] ` <dce77105-47ab-4ec7-8d46-b983c630dad8@web.de>
2023-11-07 18:48 ` Justin Chen
2023-11-08 17:46 ` Florian Fainelli
[not found] ` <38279cb8-ff60-427e-ae9f-5f973955ffa6@web.de>
2023-11-16 19:05 ` [PATCH v2] " Justin Chen
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=5e2b91e2-91a9-4b7e-a196-ae5b4a082490@intel.com \
--to=wojciech.drewek@intel.com \
--cc=Julia.Lawall@inria.fr \
--cc=Markus.Elfring@web.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=cocci@inria.fr \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=horms@kernel.org \
--cc=justin.chen@broadcom.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®