Re: [PATCH net-next V4 09/14] net/mlx5: Introduce shared devlink instance for PFs on same chip

From: Krzysztof Kozlowski

Date: Sat Nov 29 2025 - 09:08:10 EST


On 25/11/2025 21:06, Tariq Toukan wrote:
> +
> +static void mlx5_shd_destroy(struct mlx5_shd *shd)
> +{
> + list_del(&shd->list);
> + kfree(shd->sn);
> + faux_device_destroy(shd->faux_dev);
> +}
> +
> +int mlx5_shd_init(struct mlx5_core_dev *dev)
> +{
> + u8 *vpd_data __free(kfree) = NULL;

This is undesired syntax explicitly documented as one to avoid. Please
don't use cleanup.h if you do not intend to follow it.

Plus netdev dislikes cleanup, that's another point.

> + struct pci_dev *pdev = dev->pdev;
> + unsigned int vpd_size, kw_len;
> + struct mlx5_shd *shd;
> + const char *sn;
> + char *end;
> + int start;
> + int err;
> +
> + if (!mlx5_core_is_pf(dev))
> + return 0;
> +
> + vpd_data = pci_vpd_alloc(pdev, &vpd_size);

Here....

> + if (IS_ERR(vpd_data)) {
> + err = PTR_ERR(vpd_data);
> + return err == -ENODEV ? 0 : err;

And here you kfree(IS_ERR).

This is either buggy code or very confusing. Please do not use cleanup.h
if to intend not to read it.


Best regards,
Krzysztof