mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Elad Nachman <enachman@marvell.com>
To: <enachman@marvell.com>, <andrew+netdev@lunn.ch>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <yevhen.orlov@plvision.eu>,
	<taras.chornyi@plvision.eu>, <oleksandr.mazur@plvision.eu>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Dan Carpenter <error27@gmail.com>
Subject: [PATCH] net: prestera: return error on hash table init failure
Date: Mon, 14 Sep 2026 14:20:26 +0300	[thread overview]
Message-ID: <20260914112026.2822222-1-enachman@marvell.com> (raw)

From: Elad Nachman <enachman@marvell.com>

prestera_router_hw_init() calls rhashtable_destroy() on error but then
still returns success. This causes prestera_router_init() to continue
without error, going through line 1623, and call
prestera_router_hw_fini(sw), which will cause dereferencing of freed memory
'sw->router->nexthop_group_ht.tbl' at line 1560.

Fixes: 0a23ae237171 ("net: marvell: prestera: Add router nexthops ABI")
Reported-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/kernel-janitors/aqT9h61WBcslE0gJ@stanley.mountain
Signed-off-by: Elad Nachman <enachman@marvell.com>
---
 drivers/net/ethernet/marvell/prestera/prestera_router_hw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
index ccf6cf98920f..4785fcb62735 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_router_hw.c
@@ -93,7 +93,7 @@ int prestera_router_hw_init(struct prestera_switch *sw)
 err_nexthop_grp_ht_init:
 	rhashtable_destroy(&sw->router->nh_neigh_ht);
 err_nh_neigh_ht_init:
-	return 0;
+	return err;
 }
 
 void prestera_router_hw_fini(struct prestera_switch *sw)
-- 
2.25.1


             reply	other threads:[~2026-09-14 11:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 11:20 Elad Nachman [this message]
2026-09-15 23:55 ` Jacob Keller
2026-09-16  1:35 ` netdev-bot+sashiko

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=20260914112026.2822222-1-enachman@marvell.com \
    --to=enachman@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=error27@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr.mazur@plvision.eu \
    --cc=pabeni@redhat.com \
    --cc=taras.chornyi@plvision.eu \
    --cc=yevhen.orlov@plvision.eu \
    /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®