diff mbox series

[2/2] of: overlay: fix target_path memory leak

Message ID 20191118132809.30127-2-vincent.whitchurch@axis.com
State Changes Requested, archived
Headers show
Series [1/2] of: overlay: fix properties memory leak | expand

Checks

Context Check Description
robh/checkpatch success

Commit Message

Vincent Whitchurch Nov. 18, 2019, 1:28 p.m. UTC
target_path is used as a temporary buffer in dup_and_fixup_symbol_prop()
and should be freed even in the success path.

This was detected by kmemleak.

 unreferenced object 0x8598f6c0 (size 64):
   backtrace:
     __kmalloc_track_caller+0x17d/0x228
     kvasprintf+0x2b/0x64
     kasprintf+0x15/0x20
     add_changeset_property+0x225/0x364
     of_overlay_fdt_apply+0x42d/0x6b4
     ...

Fixes: e0a58f3e08d4b7fa ("of: overlay: remove a dependency on device node full_name")
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
 drivers/of/overlay.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Frank Rowand Nov. 21, 2019, 5:37 p.m. UTC | #1
Hi Rob,

On 11/18/19 7:28 AM, Vincent Whitchurch wrote:
> target_path is used as a temporary buffer in dup_and_fixup_symbol_prop()
> and should be freed even in the success path.
> 
> This was detected by kmemleak.
> 
>  unreferenced object 0x8598f6c0 (size 64):
>    backtrace:
>      __kmalloc_track_caller+0x17d/0x228
>      kvasprintf+0x2b/0x64
>      kasprintf+0x15/0x20
>      add_changeset_property+0x225/0x364
>      of_overlay_fdt_apply+0x42d/0x6b4
>      ...
> 
> Fixes: e0a58f3e08d4b7fa ("of: overlay: remove a dependency on device node full_name")
> Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
> ---
>  drivers/of/overlay.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 5f8869e2a8b3..59455322a130 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -261,6 +261,8 @@ static struct property *dup_and_fixup_symbol_prop(
>  
>  	of_property_set_flag(new_prop, OF_DYNAMIC);
>  
> +	kfree(target_path);
> +
>  	return new_prop;
>  
>  err_free_new_prop:
> 

Reviewed-by: Frank Rowand <frowand.list@gmail.com>

I would suggest changing the subject to:

   of: overlay: dup_and_fixup_symbol_prop() memory leak

but I am also fine with you not changing the subject.

-Frank
diff mbox series

Patch

diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 5f8869e2a8b3..59455322a130 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -261,6 +261,8 @@  static struct property *dup_and_fixup_symbol_prop(
 
 	of_property_set_flag(new_prop, OF_DYNAMIC);
 
+	kfree(target_path);
+
 	return new_prop;
 
 err_free_new_prop: