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] [day] [month] [year] [list]
Date:   Mon, 23 May 2022 14:10:26 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     Johan Hovold <johan@...nel.org>, cgel.zte@...il.com
Cc:     linux-kernel@...r.kernel.org, Minghao Chi <chi.minghao@....com.cn>,
        iommu@...ts.linux-foundation.org, will@...nel.org,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] iommu/ipmmu-vmsa: Avoid leak OF node on error

On 2022-05-23 12:54, Johan Hovold wrote:
> On Mon, May 23, 2022 at 11:11:45AM +0000, cgel.zte@...il.com wrote:
>> From: Minghao Chi <chi.minghao@....com.cn>
>>
>> The OF node should be put before returning error in ipmmu_init(),
>> otherwise node's refcount will be leaked.
>>
>> Reported-by: Zeal Robot <zealci@....com.cn>
>> Signed-off-by: Minghao Chi <chi.minghao@....com.cn>
>> ---
>>   drivers/iommu/ipmmu-vmsa.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
>> index 8fdb84b3642b..f6440b106f46 100644
>> --- a/drivers/iommu/ipmmu-vmsa.c
>> +++ b/drivers/iommu/ipmmu-vmsa.c
>> @@ -1179,11 +1179,10 @@ static int __init ipmmu_init(void)
>>   		return 0;
>>   
>>   	np = of_find_matching_node(NULL, ipmmu_of_ids);
>> +	of_node_put(np);
>>   	if (!np)
>>   		return 0;
>>   
>> -	of_node_put(np);
>> -
>>   	ret = platform_driver_register(&ipmmu_driver);
>>   	if (ret < 0)
>>   		return ret;
> 
> NAK

Indeed. How exactly can we hold a refcount on NULL, let alone leak it?

Static checkers are great for flagging up code that *might* have issues, 
but please actually *look* at the code and apply some thought before 
sending a patch.

Robin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ