Skip to contentSkip to conversation

net: appletalk: Fix device refcount leak in atrtr_create()

PATCH In review veritas501 2 participants 2 messages Jul 8, 2025

Subsystems (2)
lore
Share & tools
lore

veritas501

author
#0 lore raw

PATCH 1/1 net: appletalk: Fix device refcount leak in atrtr_create()

When updating an existing route entry in atrtr_create(), the old device reference was not being released before assigning the new device, leading to a device refcount leak. Fix this by calling dev_put() to release the old device reference before holding the new one.

Fixes c7f905f0f6d4 ("[ATALK]: Add missing dev_hold() to atrtr_create().")
---
 net/appletalk/ddp.c | 2 ++
 1 file changed, 2 insertions(+)
net/appletalk/ddp.c +2 -0
index 73ea7e67f05a..e5708870a249 100644
@@ -576,6 +576,8 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
 
 	/* Fill in the routing entry */
 	rt->target  = ta->sat_addr;
+	if (rt->dev)
+		dev_put(rt->dev); /* Release old device */
 	dev_hold(devhint);
 	rt->dev     = devhint;
 	rt->flags   = r->rt_flags;
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 7 lines · On Tue, 8 Jul 2025 09:04:30 +0000 veritas501 wrote:

When updating an existing route entry in atrtr_create(), the old device reference was not being released before assigning the new device, leading to a device refcount leak. Fix this by calling dev_put() to release the old device reference before holding the new one.

Fixes c7f905f0f6d4 ("[ATALK]: Add missing dev_hold() to atrtr_create().")

we need your real name

net/appletalk/ddp.c static int atrtr_create(struct rtentry *r, struct net_device *devhint) · line 580

Quoted 10 lines
net/appletalk/ddp.c +2 -0
index 73ea7e67f05a..e5708870a249 100644
@@ -576,6 +576,8 @@ static int atrtr_create(struct rtentry *r, struct net_device *devhint)
 
 	/* Fill in the routing entry */
 	rt->target  = ta->sat_addr;
+	if (rt->dev)
+		dev_put(rt->dev); /* Release old device */

null check is not necessary before dev_put()

Signature · 1 line
pw-bot: cr