From 57c038083a629effe03c45901d941d1d1eaf9adf Mon Sep 17 00:00:00 2001 From: Leonid Komarianskyi Date: Wed, 19 Apr 2023 17:17:23 +0300 Subject: [PATCH] net: renesas: rswitch: fix disabling offload with default route In case default route is set, nh structure needed for disabling offload is left uninitialized which leads to null pointer dereference. This patch adds initialization of nh in case of setting default route and fixes the issue. Reviewed-by: Volodymyr Babchuk Signed-off-by: Leonid Komarianskyi --- drivers/net/ethernet/renesas/rswitch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 3c31e2b62bb2..acf99488b985 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -2766,6 +2766,7 @@ static void rswitch_fib_event_add(struct rswitch_fib_event_work *fib_work) new_routing_list->mask = be32_to_cpu(inet_make_mask(fen.dst_len)); new_routing_list->subnet = fen.dst; new_routing_list->rdev = rdev; + new_routing_list->nh = nh; INIT_LIST_HEAD(&new_routing_list->param_list); mutex_lock(&rdev->priv->ipv4_forward_lock); @@ -2781,7 +2782,6 @@ static void rswitch_fib_event_add(struct rswitch_fib_event_work *fib_work) if (!rswitch_add_ipv4_dst_route(new_routing_list, rdev, be32_to_cpu(nh->nh_saddr))) nh->fib_nh_flags |= RTNH_F_OFFLOAD; - new_routing_list->nh = nh; } static void rswitch_fib_event_remove(struct rswitch_fib_event_work *fib_work) -- 2.25.1