[<prev] [next>] [day] [month] [year] [list]
Message-ID: <5e2b91e2-91a9-4b7e-a196-ae5b4a082490@intel.com>
Date: Mon, 6 Nov 2023 15:24:16 +0100
From: Wojciech Drewek <wojciech.drewek@...el.com>
To: Markus Elfring <Markus.Elfring@....de>,
Julia Lawall <Julia.Lawall@...ia.fr>,
"David S. Miller" <davem@...emloft.net>,
"Eric Dumazet" <edumazet@...gle.com>,
Florian Fainelli <florian.fainelli@...adcom.com>,
Jakub Kicinski <kuba@...nel.org>,
"Justin Chen" <justin.chen@...adcom.com>,
Paolo Abeni <pabeni@...hat.com>,
<bcm-kernel-feedback-list@...adcom.com>, <netdev@...r.kernel.org>,
<kernel-janitors@...r.kernel.org>
CC: <cocci@...ia.fr>, LKML <linux-kernel@...r.kernel.org>,
Simon Horman <horms@...nel.org>
Subject: Re: [PATCH] net: bcmasp: Use common error handling code in
bcmasp_probe()
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@...el.com>
>
> Regards,
> Markus
Powered by blists - more mailing lists