From: Andrew Morton <akpm@linux-foundation.org>
To: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Cc: mporter@kernel.crashing.org, alex.bou9@gmail.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net()
Date: Wed, 21 Jan 2026 13:12:01 -0800 [thread overview]
Message-ID: <20260121131201.488ea7fa63f576f22db026b6@linux-foundation.org> (raw)
In-Reply-To: <20260121013508.195836-1-lihaoxiang@isrc.iscas.ac.cn>
On Wed, 21 Jan 2026 09:35:08 +0800 Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> wrote:
> When idtab allocation fails, net is not registered with rio_add_net()
> yet, so kfree(net) is sufficient to release the memory.
> Set mport->net to NULL to avoid dangling pointer.
>
> ...
>
> --- a/drivers/rapidio/rio-scan.c
> +++ b/drivers/rapidio/rio-scan.c
> @@ -854,7 +854,8 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,
>
> if (idtab == NULL) {
> pr_err("RIO: failed to allocate destID table\n");
> - rio_free_net(net);
> + kfree(net);
> + mport->net = NULL;
Sure. Might not have any effect, but it's defensive.
> net = NULL;
> } else {
> net->enum_data = idtab;
I'll add this to the 6.20(?)-rcX queue soon, unless someone stops me.
prev parent reply other threads:[~2026-01-21 21:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 1:35 [PATCH v2] rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net() Haoxiang Li
2026-01-21 21:12 ` Andrew Morton [this message]
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=20260121131201.488ea7fa63f576f22db026b6@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alex.bou9@gmail.com \
--cc=lihaoxiang@isrc.iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=mporter@kernel.crashing.org \
--cc=stable@vger.kernel.org \
/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