Re: [PATCH] net: prestera: return error on hash table init failure
From: Jacob Keller
Date: Tue Sep 15 2026 - 19:55:48 EST
On 9/14/2026 4:20 AM, Elad Nachman wrote:
> 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;
> }
>
It looks like this snuck in because the original
prestera_router_hw_init() implementation didn't have any failure path
and always returned 0. Then commit 0a23ae237171 ("net: marvell:
prestera: Add router nexthops ABI") added some errors with handling but
did not report the error. Makes sense.
Reviewed-by: Jacob Keller <jacob.e.keller@xxxxxxxxx>
> void prestera_router_hw_fini(struct prestera_switch *sw)