Re: [PATCH] virtio_console: Convert to use devm funcs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2025-01-28 at 13:52 +0800, oushixiong1025@xxxxxxx wrote:
> From: Shixiong Ou <oushixiong@xxxxxxxxxx>
> 
> Convert to devm_* funcs so that no need to manual free in error path.
> 
> Signed-off-by: Shixiong Ou <oushixiong@xxxxxxxxxx>
> ---
>  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





[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux