From: Amit Shah <amit@kernel.org>
To: oushixiong1025@163.com
Cc: Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
Shixiong Ou <oushixiong@kylinos.cn>
Subject: Re: [PATCH] virtio_console: Convert to use devm funcs
Date: Tue, 28 Jan 2025 10:39:58 +0100 [thread overview]
Message-ID: <9a10b435045556f5625afe83bd41bc4d4f9be80b.camel@kernel.org> (raw)
In-Reply-To: <20250128055241.30760-1-oushixiong1025@163.com>
On Tue, 2025-01-28 at 13:52 +0800, oushixiong1025@163.com wrote:
> From: Shixiong Ou <oushixiong@kylinos.cn>
>
> Convert to devm_* funcs so that no need to manual free in error path.
>
> Signed-off-by: Shixiong Ou <oushixiong@kylinos.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
next prev parent reply other threads:[~2025-01-28 9:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 5:52 oushixiong1025
2025-01-28 9:39 ` Amit Shah [this message]
2025-01-29 11:48 ` oushixiong
2025-01-31 7:48 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9a10b435045556f5625afe83bd41bc4d4f9be80b.camel@kernel.org \
--to=amit@kernel.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oushixiong1025@163.com \
--cc=oushixiong@kylinos.cn \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®