<div dir="ltr">Thanks Christian for the feedback, I'll send a v2.<div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 18, 2019 at 12:31 PM Koenig, Christian <<a href="mailto:Christian.Koenig@amd.com">Christian.Koenig@amd.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am 18.09.19 um 18:09 schrieb Navid Emamdoost:<br>
> In acp_hw_init there are some allocations that needs to be released in<br>
> case of failure:<br>
><br>
> 1- adev->acp.acp_genpd should be released if any allocation attemp for<br>
> adev->acp.acp_cell, adev->acp.acp_res or i2s_pdata fails.<br>
> 2- all of those allocations should be released if pm_genpd_add_device<br>
> fails.<br>
<br>
Good catch, but please use goto error handling instead of adding more <br>
and more kfree calls.<br>
<br>
Regards,<br>
Christian.<br>
<br>
><br>
> Signed-off-by: Navid Emamdoost <<a href="mailto:navid.emamdoost@gmail.com" target="_blank">navid.emamdoost@gmail.com</a>><br>
> ---<br>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 10 +++++++++-<br>
>   1 file changed, 9 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c<br>
> index eba42c752bca..dd3fa85b11c5 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c<br>
> @@ -231,17 +231,21 @@ static int acp_hw_init(void *handle)<br>
>       adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell),<br>
>                                                       GFP_KERNEL);<br>
>   <br>
> -     if (adev->acp.acp_cell == NULL)<br>
> +     if (adev->acp.acp_cell == NULL) {<br>
> +             kfree(adev->acp.acp_genpd);<br>
>               return -ENOMEM;<br>
> +     }<br>
>   <br>
>       adev->acp.acp_res = kcalloc(5, sizeof(struct resource), GFP_KERNEL);<br>
>       if (adev->acp.acp_res == NULL) {<br>
> +             kfree(adev->acp.acp_genpd);<br>
>               kfree(adev->acp.acp_cell);<br>
>               return -ENOMEM;<br>
>       }<br>
>   <br>
>       i2s_pdata = kcalloc(3, sizeof(struct i2s_platform_data), GFP_KERNEL);<br>
>       if (i2s_pdata == NULL) {<br>
> +             kfree(adev->acp.acp_genpd);<br>
>               kfree(adev->acp.acp_res);<br>
>               kfree(adev->acp.acp_cell);<br>
>               return -ENOMEM;<br>
> @@ -348,6 +352,10 @@ static int acp_hw_init(void *handle)<br>
>               r = pm_genpd_add_device(&adev->acp.acp_genpd->gpd, dev);<br>
>               if (r) {<br>
>                       dev_err(dev, "Failed to add dev to genpd\n");<br>
> +                     kfree(adev->acp.acp_genpd);<br>
> +                     kfree(adev->acp.acp_res);<br>
> +                     kfree(adev->acp.acp_cell);<br>
> +                     kfree(i2s_pdata);<br>
>                       return r;<br>
>               }<br>
>       }<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><font color="#666666">Navid.</font></div></div></div></div>