[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190322105845.25046-1-cgxu519@gmx.com>
Date: Fri, 22 Mar 2019 18:58:45 +0800
From: Chengguang Xu <cgxu519@....com>
To: davem@...emloft.net
Cc: keescook@...omium.org, ktkhai@...tuozzo.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Chengguang Xu <cgxu519@....com>
Subject: [PATCH net] netlink: fix a memory leak on error path
In genl_register_family(), when idr_alloc() fails,
we forget to free family->attrbuf.
Note, some callers call genl_unregister_family() to clean up
on error path, it doesn't work because the family is inserted
to the global list in the nearly last step.
Fixes: 2ae0f17df1c ("genetlink: use idr to track families").
Signed-off-by: Chengguang Xu <cgxu519@....com>
---
net/netlink/genetlink.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 25eeb6d2a75a..f0ec068e1d02 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -366,7 +366,7 @@ int genl_register_family(struct genl_family *family)
start, end + 1, GFP_KERNEL);
if (family->id < 0) {
err = family->id;
- goto errout_locked;
+ goto errout_free;
}
err = genl_validate_assign_mc_groups(family);
@@ -385,6 +385,7 @@ int genl_register_family(struct genl_family *family)
errout_remove:
idr_remove(&genl_fam_idr, family->id);
+errout_free:
kfree(family->attrbuf);
errout_locked:
genl_unlock_all();
--
2.20.1
Powered by blists - more mailing lists