From: oushixiong <oushixiong1025@163.com>
To: Amit Shah <amit@kernel.org>
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: Wed, 29 Jan 2025 19:48:10 +0800 [thread overview]
Message-ID: <0e5fcde2-140a-4896-8880-5f90f2a134c4@163.com> (raw)
In-Reply-To: <9a10b435045556f5625afe83bd41bc4d4f9be80b.camel@kernel.org>
在 2025/1/28 17:39, Amit Shah 写道:
> 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
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
next prev parent reply other threads:[~2025-01-29 11:48 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
2025-01-29 11:48 ` oushixiong [this message]
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=0e5fcde2-140a-4896-8880-5f90f2a134c4@163.com \
--to=oushixiong1025@163.com \
--cc=amit@kernel.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--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®