Skip to content
/ linux Public

Commit e5a732b

Browse files
Haoxiang LiSasha Levin
authored andcommitted
rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net()
[ Upstream commit 666183d ] 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. Link: https://lkml.kernel.org/r/20260121013508.195836-1-lihaoxiang@isrc.iscas.ac.cn Fixes: e6b585c ("rapidio: move net allocation into core code") Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Alexandre Bounine <alex.bou9@gmail.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9f7a5ae commit e5a732b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/rapidio/rio-scan.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,8 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,
854854

855855
if (idtab == NULL) {
856856
pr_err("RIO: failed to allocate destID table\n");
857-
rio_free_net(net);
857+
kfree(net);
858+
mport->net = NULL;
858859
net = NULL;
859860
} else {
860861
net->enum_data = idtab;

0 commit comments

Comments
 (0)