Re: [PATCH v2 1/2] nvdimm: Fix devs leaks in scan_labels()
From: Zhijian Li (Fujitsu)
Date: Mon Aug 19 2024 - 02:05:28 EST
On 10/08/2024 06:55, Dan Williams wrote:
> Dan Williams wrote:
> [..]
>> @@ -2036,12 +2038,10 @@ static struct device **scan_labels(struct nd_region *nd_region)
>
> ...of course you would also need something like:
>
> if (!count) {
> kfree(devs);
> return NULL;
> }
It seems we don't need this cleanup, in the count=0 case, we would reach `err` to free devs.
Thanks
Zhijian
>
> ...here, I'll leave that to you to fix up and test.
>
>> return devs;
>>
>> err:
>> - if (devs) {
>> - for (i = 0; devs[i]; i++)
>> - namespace_pmem_release(devs[i]);
>> - kfree(devs);
>> - }
>> - return NULL;
>> + for (i = 0; devs[i]; i++)
>> + namespace_pmem_release(devs[i]);
>> + kfree(devs);
>> + return NULL;
>> }
>>