Re: [PATCH net-next v02 4/6] hinic3: Add mac filter ops

From: Fan Gong

Date: Sun Oct 19 2025 - 21:29:59 EST


On 10/17/2025 7:51 PM, Markus Elfring wrote:
> …> +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_filter.c
>> @@ -0,0 +1,413 @@
> …> +static int hinic3_mac_filter_sync(struct net_device *netdev,
>> + struct list_head *mac_filter_list, bool uc)
>> +{
>
>> + hinic3_cleanup_filter_list(&tmp_add_list);> + hinic3_mac_filter_sync_hw(netdev, &tmp_del_list, &tmp_add_list);
>> +
>> + /* need to enter promiscuous/allmulti mode */
>> + err = -ENOMEM;
>> + goto err_out;
>> + }
>> +
>> + return add_count;
>> +
>> +err_out:
>> + return err;
>> +}
>
> Is there a need to move any resource cleanup actions behind a more appropriate label?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.17#n532
>
>
> Regards,
> Markus

Hi, Markus. Thanks for your comment.

Your suggestion is great. In "hinic3_mac_filter_sync", there are two places in
the code that return error values.
Actually the error handling code you quoted should be refined as a new function
because its error handling is special and cannot be normalized to function error
path.

> + if (err) {
> + hinic3_undo_del_filter_entries(mac_filter_list, &tmp_del_list);
> + hinic3_undo_add_filter_entries(mac_filter_list, &tmp_add_list);
> + netdev_err(netdev, "Failed to clone mac_filter_entry\n");
> +
> + hinic3_cleanup_filter_list(&tmp_del_list);
> + hinic3_cleanup_filter_list(&tmp_add_list);
> + goto err_out;
> + }

And anther place(only cleanup del_list & add_list) should be moved behind a
error label in function error path according to linux doc.