git: efa14ab698fe - main - routing: Fix nhop double free in rib_copy_route()

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 21:55:40 UTC
The branch main has been updated by pouria:

URL: https://cgit.FreeBSD.org/src/commit/?id=efa14ab698fe5c3a1586aec006f98e3781f4af78

commit efa14ab698fe5c3a1586aec006f98e3781f4af78
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-11-12 21:34:06 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-11-12 21:48:57 +0000

    routing: Fix nhop double free in rib_copy_route()
    
    add_route_flags() consumes the nexthop reference on every
    failure path, so nhop_free() in rib_copy_route() releases it for
    the second time.
    
    This is reachable when growing net.fibs while two existing fibs
    hold the same pinned prefix.
    
    MFC after:      3 days
    Fixes:  40503b792f7e ("routing: populate fibs with interface...")
---
 sys/net/route/route_ctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sys/net/route/route_ctl.c b/sys/net/route/route_ctl.c
index ef58a2845424..4fd961689576 100644
--- a/sys/net/route/route_ctl.c
+++ b/sys/net/route/route_ctl.c
@@ -657,7 +657,6 @@ rib_copy_route(struct rtentry *rt, const struct route_nhop_data *rnd_src,
 			FIB_RH_LOG(LOG_DEBUG, rh_dst,
 			    "Unable to add route %s: error %d", buf, error);
 		}
-		nhop_free(nh);
 	}
 	return (error);
 }