git: 9798193157fd - stable/15 - routing: Fix nhop double free in rib_copy_route()

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Fri, 27 Nov 2026 08:35:46 UTC
The branch stable/15 has been updated by pouria:

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

commit 9798193157fd8ab112adee68ddd7f07bb5491716
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-27 06:27:38 +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...")
    
    (cherry picked from commit efa14ab698fe5c3a1586aec006f98e3781f4af78)
---
 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 d629fd1625c3..79ca07638236 100644
--- a/sys/net/route/route_ctl.c
+++ b/sys/net/route/route_ctl.c
@@ -677,7 +677,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);
 }