2023-11-06 14:37:32

by Wojciech Drewek

[permalink] [raw]
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 <[email protected]>

>
> Regards,
> Markus