lkml.org 
[lkml]   [2019]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] regulator: of: Add of_node_put() before return in function
From
Date
On 24/07/19 9:17 PM, Mark Brown wrote:
> On Wed, Jul 24, 2019 at 02:02:31PM +0530, Nishka Dasgupta wrote:
>> The local variable search in regulator_of_get_init_node takes the value
>> returned by either of_get_child_by_name or of_node_get, both of which
>> get a node. If this node is not put before returning, it could cause a
>> memory leak. Hence put search before a mid-loop return statement.
>> Issue found with Coccinelle.
>
>> - if (!strcmp(desc->of_match, name))
>> + if (!strcmp(desc->of_match, name)) {
>> + of_node_put(search);
>> return of_node_get(child);
>> + }
>
> Why not just remove the extra of_node_get() and a comment explaining why
> it's not needed?
>
I'm sorry, I don't think I understand. I'm putting search in this patch;
the program was already getting child. Should I also return child
directly instead of getting it again, and continue to put search?

Thanking you,
Nishka

\
 
 \ /
  Last update: 2019-07-26 09:33    [W:0.071 / U:1.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site