linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] reset: Fix memory leak in reset_control_array_put()
@ 2019-10-22  8:36 Kishon Vijay Abraham I
  2019-10-22  9:00 ` Philipp Zabel
  0 siblings, 1 reply; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2019-10-22  8:36 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel, Kishon Vijay Abraham I

Memory allocated for 'struct reset_control_array' in
of_reset_control_array_get() is never freed in
reset_control_array_put() resulting in kmemleak showing
the following backtrace.

  backtrace:
    [<00000000c5f17595>] __kmalloc+0x1b0/0x2b0
    [<00000000bd499e13>] of_reset_control_array_get+0xa4/0x180
    [<000000004cc02754>] 0xffff800008c669e4
    [<0000000050a83b24>] platform_drv_probe+0x50/0xa0
    [<00000000d3a0b0bc>] really_probe+0x108/0x348
    [<000000005aa458ac>] driver_probe_device+0x58/0x100
    [<000000008853626c>] device_driver_attach+0x6c/0x90
    [<0000000085308d19>] __driver_attach+0x84/0xc8
    [<00000000080d35f2>] bus_for_each_dev+0x74/0xc8
    [<00000000dd7f015b>] driver_attach+0x20/0x28
    [<00000000923ba6e6>] bus_add_driver+0x148/0x1f0
    [<0000000061473b66>] driver_register+0x60/0x110
    [<00000000c5bec167>] __platform_driver_register+0x40/0x48
    [<000000007c764b4f>] 0xffff800008c6c020
    [<0000000047ec2e8c>] do_one_initcall+0x5c/0x1b0
    [<0000000093d4b50d>] do_init_module+0x54/0x1d0

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 drivers/reset/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 213ff40dda11..36b1ff69b1e2 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -748,6 +748,7 @@ static void reset_control_array_put(struct reset_control_array *resets)
 	for (i = 0; i < resets->num_rstcs; i++)
 		__reset_control_put_internal(resets->rstc[i]);
 	mutex_unlock(&reset_list_mutex);
+	kfree(resets);
 }
 
 /**
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] reset: Fix memory leak in reset_control_array_put()
  2019-10-22  8:36 [PATCH] reset: Fix memory leak in reset_control_array_put() Kishon Vijay Abraham I
@ 2019-10-22  9:00 ` Philipp Zabel
  2019-10-22 10:15   ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Zabel @ 2019-10-22  9:00 UTC (permalink / raw)
  To: Kishon Vijay Abraham I; +Cc: linux-kernel

Hi Kishon,

On Tue, 2019-10-22 at 14:06 +0530, Kishon Vijay Abraham I wrote:
> Memory allocated for 'struct reset_control_array' in
> of_reset_control_array_get() is never freed in
> reset_control_array_put() resulting in kmemleak showing
> the following backtrace.
> 
>   backtrace:
>     [<00000000c5f17595>] __kmalloc+0x1b0/0x2b0
>     [<00000000bd499e13>] of_reset_control_array_get+0xa4/0x180
>     [<000000004cc02754>] 0xffff800008c669e4
>     [<0000000050a83b24>] platform_drv_probe+0x50/0xa0
>     [<00000000d3a0b0bc>] really_probe+0x108/0x348
>     [<000000005aa458ac>] driver_probe_device+0x58/0x100
>     [<000000008853626c>] device_driver_attach+0x6c/0x90
>     [<0000000085308d19>] __driver_attach+0x84/0xc8
>     [<00000000080d35f2>] bus_for_each_dev+0x74/0xc8
>     [<00000000dd7f015b>] driver_attach+0x20/0x28
>     [<00000000923ba6e6>] bus_add_driver+0x148/0x1f0
>     [<0000000061473b66>] driver_register+0x60/0x110
>     [<00000000c5bec167>] __platform_driver_register+0x40/0x48
>     [<000000007c764b4f>] 0xffff800008c6c020
>     [<0000000047ec2e8c>] do_one_initcall+0x5c/0x1b0
>     [<0000000093d4b50d>] do_init_module+0x54/0x1d0
> 
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/reset/core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 213ff40dda11..36b1ff69b1e2 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -748,6 +748,7 @@ static void reset_control_array_put(struct reset_control_array *resets)
>  	for (i = 0; i < resets->num_rstcs; i++)
>  		__reset_control_put_internal(resets->rstc[i]);
>  	mutex_unlock(&reset_list_mutex);
> +	kfree(resets);
>  }
>  
>  /**

Thank you for the patch! I've added a

Fixes: 17c82e206d2a ("reset: Add APIs to manage array of resets")

tag and applied it to my reset/fixes branch.

regards
Philipp


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] reset: Fix memory leak in reset_control_array_put()
  2019-10-22  9:00 ` Philipp Zabel
@ 2019-10-22 10:15   ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 3+ messages in thread
From: Kishon Vijay Abraham I @ 2019-10-22 10:15 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-kernel



On 22/10/19 2:30 PM, Philipp Zabel wrote:
> Hi Kishon,
> 
> On Tue, 2019-10-22 at 14:06 +0530, Kishon Vijay Abraham I wrote:
>> Memory allocated for 'struct reset_control_array' in
>> of_reset_control_array_get() is never freed in
>> reset_control_array_put() resulting in kmemleak showing
>> the following backtrace.
>>
>>   backtrace:
>>     [<00000000c5f17595>] __kmalloc+0x1b0/0x2b0
>>     [<00000000bd499e13>] of_reset_control_array_get+0xa4/0x180
>>     [<000000004cc02754>] 0xffff800008c669e4
>>     [<0000000050a83b24>] platform_drv_probe+0x50/0xa0
>>     [<00000000d3a0b0bc>] really_probe+0x108/0x348
>>     [<000000005aa458ac>] driver_probe_device+0x58/0x100
>>     [<000000008853626c>] device_driver_attach+0x6c/0x90
>>     [<0000000085308d19>] __driver_attach+0x84/0xc8
>>     [<00000000080d35f2>] bus_for_each_dev+0x74/0xc8
>>     [<00000000dd7f015b>] driver_attach+0x20/0x28
>>     [<00000000923ba6e6>] bus_add_driver+0x148/0x1f0
>>     [<0000000061473b66>] driver_register+0x60/0x110
>>     [<00000000c5bec167>] __platform_driver_register+0x40/0x48
>>     [<000000007c764b4f>] 0xffff800008c6c020
>>     [<0000000047ec2e8c>] do_one_initcall+0x5c/0x1b0
>>     [<0000000093d4b50d>] do_init_module+0x54/0x1d0
>>
>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>> ---
>>  drivers/reset/core.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
>> index 213ff40dda11..36b1ff69b1e2 100644
>> --- a/drivers/reset/core.c
>> +++ b/drivers/reset/core.c
>> @@ -748,6 +748,7 @@ static void reset_control_array_put(struct reset_control_array *resets)
>>  	for (i = 0; i < resets->num_rstcs; i++)
>>  		__reset_control_put_internal(resets->rstc[i]);
>>  	mutex_unlock(&reset_list_mutex);
>> +	kfree(resets);
>>  }
>>  
>>  /**
> 
> Thank you for the patch! I've added a
> 
> Fixes: 17c82e206d2a ("reset: Add APIs to manage array of resets")
> 
> tag and applied it to my reset/fixes branch.

That was quick! Thanks!

-Kishon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-22 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-22  8:36 [PATCH] reset: Fix memory leak in reset_control_array_put() Kishon Vijay Abraham I
2019-10-22  9:00 ` Philipp Zabel
2019-10-22 10:15   ` Kishon Vijay Abraham I

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).