All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+3f2d46b6e62b8dd546d3@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] netrom: fix memory leak in nr_add_node()
Date: Thu, 15 Jan 2026 18:19:16 -0800	[thread overview]
Message-ID: <6969a024.050a0220.58bed.0036.GAE@google.com> (raw)
In-Reply-To: <69694849.050a0220.58bed.0025.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] netrom: fix memory leak in nr_add_node()
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

When nr_add_node() creates a new neighbor but the route quality is too
low to be added (node already has 3 routes with better quality), the
newly allocated neighbor is never used but remains in the neighbor list
with refcount=1, causing a memory leak.

Fix by checking if the new neighbor was actually used (count > 0) and
removing it from the list if not.

Reported-by: syzbot+3f2d46b6e62b8dd546d3@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 net/netrom/nr_route.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index b94cb2ffbaf8..4b85bacb7f65 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -100,6 +100,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
 {
 	struct nr_node  *nr_node;
 	struct nr_neigh *nr_neigh;
+	bool new_neigh = false;
 	int i, found;
 	struct net_device *odev;
 
@@ -172,6 +173,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
 			}
 		}
 
+		new_neigh = true;
 		spin_lock_bh(&nr_neigh_list_lock);
 		hlist_add_head(&nr_neigh->neigh_node, &nr_neigh_list);
 		nr_neigh_hold(nr_neigh);
@@ -279,6 +281,9 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
 		}
 	}
 
+	if (new_neigh && nr_neigh->count == 0)
+		nr_remove_neigh(nr_neigh);
+
 	nr_neigh_put(nr_neigh);
 	nr_node_unlock(nr_node);
 	nr_node_put(nr_node);
-- 
2.43.0


  reply	other threads:[~2026-01-16  2:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-15 20:04 [syzbot] [hams?] memory leak in nr_add_node syzbot
2026-01-16  2:19 ` syzbot [this message]
2026-01-16  3:40 ` Forwarded: [PATCH] netrom: fix memory leak in nr_add_node() syzbot
2026-01-16  7:42 ` syzbot
2026-01-16  8:28 ` syzbot
2026-01-16  8:59 ` syzbot
2026-01-16  9:39 ` syzbot
2026-01-16 12:51 ` syzbot
2026-01-17 14:26 ` Testing for netrom: fix memory leak in nr_add_node Prithvi Tambewagh
2026-01-17 17:00   ` [syzbot] [hams?] " syzbot
2026-01-19 21:06   ` Testing for netrom: fix " F6BVP
2026-01-20  3:37     ` David Ranch
2026-01-20 16:00       ` Prithvi
2026-01-20 21:02         ` F6BVP
2026-01-22 17:27           ` Prithvi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6969a024.050a0220.58bed.0036.GAE@google.com \
    --to=syzbot+3f2d46b6e62b8dd546d3@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.