diff mbox

[1/3] DMA: PL330: Free memory allocated for peripheral channels

Message ID 1348563456-30569-2-git-send-email-inderpal.singh@linaro.org
State New
Headers show

Commit Message

Inderpal Singh Sept. 25, 2012, 8:57 a.m. UTC
The allocated memory for peripheral channels is not being freed upon
failure in probe and in module's remove funtion. It will lead to memory
leakage. Hence free the allocated memory.

Signed-off-by: Inderpal Singh <inderpal.singh@linaro.org>
---
 drivers/dma/pl330.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jassi Brar Sept. 25, 2012, 12:47 p.m. UTC | #1
On Tue, Sep 25, 2012 at 2:27 PM, Inderpal Singh
<inderpal.singh@linaro.org> wrote:
> The allocated memory for peripheral channels is not being freed upon
> failure in probe and in module's remove funtion. It will lead to memory
> leakage. Hence free the allocated memory.
>
> Signed-off-by: Inderpal Singh <inderpal.singh@linaro.org>
> ---
>  drivers/dma/pl330.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
> index 2ebd4cd..10c6b6a 100644
> --- a/drivers/dma/pl330.c
> +++ b/drivers/dma/pl330.c
> @@ -2962,7 +2962,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>         ret = dma_async_device_register(pd);
>         if (ret) {
>                 dev_err(&adev->dev, "unable to register DMAC\n");
> -               goto probe_err4;
> +               goto probe_err5;
>         }
>
Sorry this patch seems malformed. Against which tree did you prepare it ?

-jassi



>         dev_info(&adev->dev,
> @@ -2975,6 +2975,8 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>
>         return 0;
>
> +probe_err5:
> +       kfree(pdmac->peripherals);
>  probe_err4:
>         pl330_del(pi);
>  probe_err3:
> @@ -3025,6 +3027,7 @@ static int __devexit pl330_remove(struct amba_device *adev)
>         res = &adev->res;
>         release_mem_region(res->start, resource_size(res));
>
> +       kfree(pdmac->peripherals);
>         kfree(pdmac);
>
>         return 0;
> --
> 1.7.9.5
>
Inderpal Singh Sept. 25, 2012, 3:23 p.m. UTC | #2
On 25 September 2012 18:17, Jassi Brar <jassisinghbrar@gmail.com> wrote:
> On Tue, Sep 25, 2012 at 2:27 PM, Inderpal Singh
> <inderpal.singh@linaro.org> wrote:
>> The allocated memory for peripheral channels is not being freed upon
>> failure in probe and in module's remove funtion. It will lead to memory
>> leakage. Hence free the allocated memory.
>>
>> Signed-off-by: Inderpal Singh <inderpal.singh@linaro.org>
>> ---
>>  drivers/dma/pl330.c |    5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
>> index 2ebd4cd..10c6b6a 100644
>> --- a/drivers/dma/pl330.c
>> +++ b/drivers/dma/pl330.c
>> @@ -2962,7 +2962,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>>         ret = dma_async_device_register(pd);
>>         if (ret) {
>>                 dev_err(&adev->dev, "unable to register DMAC\n");
>> -               goto probe_err4;
>> +               goto probe_err5;
>>         }
>>
> Sorry this patch seems malformed. Against which tree did you prepare it ?
>
This patch depends on "61c6e7531d3b66b3 ........DMA: PL330: Check the
pointer returned by kzalloc" which is on vinod's slave-dma's "fixes"
branch. So I merged slave-dma's "next" and "fixes" branches. Now after
merging, build error occurs due to some conflict so I had to apply the
patch sent by Sachin at [1]

Same had been mentioned in the cover letter.

[1] http://permalink.gmane.org/gmane.linux.kernel.next/24274

Thanks,
Inder

> -jassi
>
>
>
>>         dev_info(&adev->dev,
>> @@ -2975,6 +2975,8 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
>>
>>         return 0;
>>
>> +probe_err5:
>> +       kfree(pdmac->peripherals);
>>  probe_err4:
>>         pl330_del(pi);
>>  probe_err3:
>> @@ -3025,6 +3027,7 @@ static int __devexit pl330_remove(struct amba_device *adev)
>>         res = &adev->res;
>>         release_mem_region(res->start, resource_size(res));
>>
>> +       kfree(pdmac->peripherals);
>>         kfree(pdmac);
>>
>>         return 0;
>> --
>> 1.7.9.5
>>
diff mbox

Patch

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 2ebd4cd..10c6b6a 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -2962,7 +2962,7 @@  pl330_probe(struct amba_device *adev, const struct amba_id *id)
 	ret = dma_async_device_register(pd);
 	if (ret) {
 		dev_err(&adev->dev, "unable to register DMAC\n");
-		goto probe_err4;
+		goto probe_err5;
 	}
 
 	dev_info(&adev->dev,
@@ -2975,6 +2975,8 @@  pl330_probe(struct amba_device *adev, const struct amba_id *id)
 
 	return 0;
 
+probe_err5:
+	kfree(pdmac->peripherals);
 probe_err4:
 	pl330_del(pi);
 probe_err3:
@@ -3025,6 +3027,7 @@  static int __devexit pl330_remove(struct amba_device *adev)
 	res = &adev->res;
 	release_mem_region(res->start, resource_size(res));
 
+	kfree(pdmac->peripherals);
 	kfree(pdmac);
 
 	return 0;