If omap4_keypad_parse_dt() does not return 0 (zero) in
omap4_keypad_probe() we will leak the memory we allocated for
'keypad_data' with kzalloc() when we return and the variable goes out
of scope.
Fix the leak by jumping to the 'err_free_keypad' label where we
properly free the allocated memory, instead of returning directly.
Signed-off-by: Jesper Juhl <redacted>
---
drivers/input/keyboard/omap4-keypad.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Compile tested only.
On 7 August 2012 23:46, Jesper Juhl [off-list ref] wrote:
If omap4_keypad_parse_dt() does not return 0 (zero) in
omap4_keypad_probe() we will leak the memory we allocated for
'keypad_data' with kzalloc() when we return and the variable goes out
of scope.
How about using devm_kzalloc() instead which will take care of freeing
the memory on detach?
quoted hunk
Fix the leak by jumping to the 'err_free_keypad' label where we
properly free the allocated memory, instead of returning directly.
Signed-off-by: Jesper Juhl <redacted>
---
drivers/input/keyboard/omap4-keypad.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Compile tested only.
On 7 August 2012 23:46, Jesper Juhl [off-list ref] wrote:
quoted
If omap4_keypad_parse_dt() does not return 0 (zero) in
omap4_keypad_probe() we will leak the memory we allocated for
'keypad_data' with kzalloc() when we return and the variable goes out
of scope.
How about using devm_kzalloc() instead which will take care of freeing
the memory on detach?
On Wednesday, August 08, 2012 09:36:51 PM Jesper Juhl wrote:
On Wed, 8 Aug 2012, Sachin Kamat wrote:
quoted
On 7 August 2012 23:46, Jesper Juhl [off-list ref] wrote:
quoted
If omap4_keypad_parse_dt() does not return 0 (zero) in
omap4_keypad_probe() we will leak the memory we allocated for
'keypad_data' with kzalloc() when we return and the variable goes out
of scope.
How about using devm_kzalloc() instead which will take care of freeing
the memory on detach?
Perhaps. I'm not (yet) familiar with how that function works, so I had
not considered it. I'll look into it.
Actually please not yet - I guess at some point I'll have to add devm_*
variants for input_device_* operations but for now I prefer not to mix
the 2 styles of managing resources.
BTW, I think I need to redo a few patches so I plan on folding this fix
into the original change.
Thanks.
--
Dmitry
On Wednesday, August 08, 2012 09:36:51 PM Jesper Juhl wrote:
quoted
On Wed, 8 Aug 2012, Sachin Kamat wrote:
quoted
On 7 August 2012 23:46, Jesper Juhl [off-list ref] wrote:
quoted
If omap4_keypad_parse_dt() does not return 0 (zero) in
omap4_keypad_probe() we will leak the memory we allocated for
'keypad_data' with kzalloc() when we return and the variable goes out
of scope.
How about using devm_kzalloc() instead which will take care of freeing
the memory on detach?
Perhaps. I'm not (yet) familiar with how that function works, so I had
not considered it. I'll look into it.
Actually please not yet - I guess at some point I'll have to add devm_*
variants for input_device_* operations but for now I prefer not to mix
the 2 styles of managing resources.
BTW, I think I need to redo a few patches so I plan on folding this fix
into the original change.