netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: appletalk: Fix device refcount leak in atrtr_create()
@ 2025-07-08  9:04 veritas501
  2025-07-08 13:04 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: veritas501 @ 2025-07-08  9:04 UTC (permalink / raw)
  To: davem
  Cc: veritas501, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Ingo Molnar, Thomas Gleixner, Herbert Xu, netdev,
	linux-kernel

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().")
Signed-off-by: veritas501 <hxzene@gmail.com>
---
 net/appletalk/ddp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 73ea7e67f05a..e5708870a249 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: appletalk: Fix device refcount leak in atrtr_create()
  2025-07-08  9:04 [PATCH] net: appletalk: Fix device refcount leak in atrtr_create() veritas501
@ 2025-07-08 13:04 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-07-08 13:04 UTC (permalink / raw)
  To: veritas501
  Cc: davem, Eric Dumazet, Paolo Abeni, Simon Horman, Ingo Molnar,
	Thomas Gleixner, Herbert Xu, netdev, linux-kernel

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().")
> Signed-off-by: veritas501 <hxzene@gmail.com>

we need your real name

> diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
> index 73ea7e67f05a..e5708870a249 100644
> --- a/net/appletalk/ddp.c
> +++ b/net/appletalk/ddp.c
> @@ -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()
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-08 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08  9:04 [PATCH] net: appletalk: Fix device refcount leak in atrtr_create() veritas501
2025-07-08 13:04 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).