[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20260121131201.488ea7fa63f576f22db026b6@linux-foundation.org>
Date: Wed, 21 Jan 2026 13:12:01 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Haoxiang Li <lihaoxiang@...c.iscas.ac.cn>
Cc: mporter@...nel.crashing.org, alex.bou9@...il.com,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] rapidio: replace rio_free_net() with kfree() in
rio_scan_alloc_net()
On Wed, 21 Jan 2026 09:35:08 +0800 Haoxiang Li <lihaoxiang@...c.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.
Powered by blists - more mailing lists