[PATCH] net: prestera: return error on hash table init failure
From: Elad Nachman
Date: Mon Sep 14 2026 - 07:27:37 EST
From: Elad Nachman <enachman@xxxxxxxxxxx>
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@xxxxxxxxx>
Link: https://lore.kernel.org/kernel-janitors/aqT9h61WBcslE0gJ@stanley.mountain
Signed-off-by: Elad Nachman <enachman@xxxxxxxxxxx>
---
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