lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8a1fa50a-3d1f-427d-c319-be2c6f5ccb6b@gmail.com>
Date:   Wed, 31 Jul 2019 18:41:03 +0530
From:   Nishka Dasgupta <nishkadg.linux@...il.com>
To:     Mark Brown <broonie@...nel.org>
Cc:     lgirdwood@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] regulator: of: Add of_node_put() before return in
 function

On 26/07/19 4:15 PM, Mark Brown wrote:
> On Fri, Jul 26, 2019 at 01:02:52PM +0530, Nishka Dasgupta wrote:
>> 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?
> 
> Your new code is dropping a reference then immediately reacquiring one
> to return it (introducing a race condition along the way).  Why not just
> return the already held reference and not call any functions at all?
> 
I still don't understand.
Previously the function was acquiring a reference to child with 
of_node_get().
My added code is dropping a reference to search, using of_node_put().
I'm probably misunderstanding this at some point, but I thought search 
and child are two different nodes? Or am I completely misunderstanding 
what you're explaining?
Apologies for the confusion.

Thanking you,
Nishka

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ