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]
Message-ID: <0e5fcde2-140a-4896-8880-5f90f2a134c4@163.com>
Date: Wed, 29 Jan 2025 19:48:10 +0800
From: oushixiong <oushixiong1025@....com>
To: Amit Shah <amit@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 virtualization@...ts.linux.dev, linux-kernel@...r.kernel.org,
 Shixiong Ou <oushixiong@...inos.cn>
Subject: Re: [PATCH] virtio_console: Convert to use devm funcs


在 2025/1/28 17:39, Amit Shah 写道:
> On Tue, 2025-01-28 at 13:52 +0800, oushixiong1025@....com wrote:
>> From: Shixiong Ou <oushixiong@...inos.cn>
>>
>> Convert to devm_* funcs so that no need to manual free in error path.
>>
>> Signed-off-by: Shixiong Ou <oushixiong@...inos.cn>
>> ---
>>   drivers/char/virtio_console.c | 43 ++++++++++++++-------------------
>> --
>>   1 file changed, 17 insertions(+), 26 deletions(-)
> [...]
>
>> -		goto free;
>> +		return err;
> [...]
>
>> -
>> -free:
>> -	kfree(portdev->out_vqs);
>> -	kfree(portdev->in_vqs);
>> -	kfree(vqs_info);
>> -	kfree(vqs);
>> -
>> -	return err;
>>   }
> Hm, I'm not entirely sure about this - the devm_ interface is better,
> but to me that just says that it's an extra safety net that avoids
> memleaks when we forget to kfree, and not that we deliberately do not
> free and get lax about managing allocated memory.
>
> So I'd prefer a patch that keeps all current frees as they are, but
> with the added advantage of using the devm interfaces.
>
> 		Amit

Hi, I don't think driver need to  call kfree() by manual if driver use 
the devm_ interface

in the probe() phase. This can simplifies the code.

This is similar to the  commit  "55dd7378ba94 (fbdev: imxfb: Convert to 
devm_kmalloc_array())"

Thanks!

Shixiong Ou


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ