On Fri, May 23, 2025 at 12:04:31PM -0500, Tatyana Nikolova wrote:
> From: Joshua Hay <[email protected]>
> 
> Add the initial idpf_idc.c file with the functions to kick off the IDC
> initialization, create and initialize a core RDMA auxiliary device, and
> destroy said device.
> 
> The RDMA core has a dependency on the vports being created by the
> control plane before it can be initialized. Therefore, once all the
> vports are up after a hard reset (either during driver load or a function
> level reset), the core RDMA device info will be created. It is populated
> with the function type (as distinguished by the IDC initialization
> function pointer), the core idc_ops function points (just stubs for
> now), the reserved RDMA MSIX table, and various other info the core RDMA
> auxiliary driver will need. It is then plugged on to the bus.
> 
> During a function level reset or driver unload, the device will be
> unplugged from the bus and destroyed.
> 
> Reviewed-by: Madhu Chittim <[email protected]>
> Signed-off-by: Joshua Hay <[email protected]>
> Signed-off-by: Tatyana Nikolova <[email protected]>

...

> diff --git a/drivers/net/ethernet/intel/idpf/idpf_idc.c 
> b/drivers/net/ethernet/intel/idpf/idpf_idc.c

...

> +/**
> + * idpf_idc_init_aux_core_dev - initialize Auxiliary Device(s)
> + * @adapter: driver private data structure
> + * @ftype: PF or VF
> + *
> + * Return: 0 on success or error code on failure.
> + */
> +int idpf_idc_init_aux_core_dev(struct idpf_adapter *adapter,
> +                            enum iidc_function_type ftype)
> +{
> +     struct iidc_rdma_core_dev_info *cdev_info;
> +     struct iidc_rdma_priv_dev_info *privd;
> +     int err;
> +
> +     adapter->cdev_info = kzalloc(sizeof(*cdev_info), GFP_KERNEL);
> +     if (!adapter->cdev_info)
> +             return -ENOMEM;
> +
> +     privd = kzalloc(sizeof(*privd), GFP_KERNEL);
> +     if (!privd) {
> +             err = -ENOMEM;
> +             goto err_privd_alloc;

Hi Joshua, Tatyana, all,

Jumping to err_privd_alloc will free cdev_info.
However cdev_info isn't initialised until a few lines
further down.

Flagged by Smatch.

> +     }
> +
> +     cdev_info = adapter->cdev_info;
> +     cdev_info->iidc_priv = privd;
> +     cdev_info->pdev = adapter->pdev;
> +     cdev_info->rdma_protocol = IIDC_RDMA_PROTOCOL_ROCEV2;
> +     privd->ftype = ftype;
> +
> +     idpf_idc_init_msix_data(adapter);
> +
> +     err = idpf_plug_core_aux_dev(cdev_info);
> +     if (err)
> +             goto err_plug_aux_dev;
> +
> +     return 0;
> +
> +err_plug_aux_dev:
> +     kfree(privd);
> +err_privd_alloc:
> +     kfree(cdev_info);
> +     adapter->cdev_info = NULL;
> +
> +     return err;
> +}

...

Reply via email to