[PATCH v3 11/18] cxl: Separate bare-metal fields in adapter and AFU data structures

Ian Munsie imunsie at au1.ibm.com
Wed Feb 10 20:04:32 AEDT 2016


> @@ -825,6 +826,14 @@ static int pci_init_afu(struct cxl *adapter, int slice, struct pci_dev *dev)
>      if (!afu)
>          return -ENOMEM;
>  
> +    afu->native = kzalloc(sizeof(struct cxl_afu_native), GFP_KERNEL);
> +    if (!afu->native) {
> +        kfree(afu);
> +        return -ENOMEM;
> +    }

This function is already using goto style error paths, so it would be
better to use it since you have some common cleanup to do:

int rc = -ENOMEM;

...

    if (!afu->native)
        goto err_free_afu;

...

err_free_afu_native:
    kfree(afu->native);
err_free_afu:
    kfree(afu);
    return rc;

> @@ -1162,6 +1173,13 @@ static struct cxl *cxl_pci_init_adapter(struct pci_dev *dev)
>      if (!adapter)
>          return ERR_PTR(-ENOMEM);
>  
> +    adapter->native = kzalloc(sizeof(struct cxl_native), GFP_KERNEL);
> +    if (!adapter->native) {
> +        pci_disable_device(dev);
> +        cxl_release_adapter(&adapter->dev);
> +        return ERR_PTR(-ENOMEM);

Likewise, since there is now some cleanup in this error path that is
part in common with another error path in the function change both error
paths to use goto style error handling.



More information about the Linuxppc-dev mailing list