diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2016-11-03 09:42:35 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-03 16:52:29 -0400 |
commit | 00ffc1ba02d876478c125e4305f9a02d40c6d284 (patch) | |
tree | c21c7a5a82b60085cd8b987d983c78a2443ecb05 /net | |
parent | 990ff4d84408fc55942ca6644f67e361737b3d8e (diff) | |
download | linux-00ffc1ba02d876478c125e4305f9a02d40c6d284.tar.gz linux-00ffc1ba02d876478c125e4305f9a02d40c6d284.tar.bz2 linux-00ffc1ba02d876478c125e4305f9a02d40c6d284.zip |
genetlink: fix a memory leak on error path
In __genl_register_family(), when genl_validate_assign_mc_groups()
fails, we forget to free the memory we possibly allocate for
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.
Cc: Jakub Kicinski <kubakici@wp.pl>
Cc: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netlink/genetlink.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 23cc12639ba7..49c28e8ef01b 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -404,7 +404,7 @@ int __genl_register_family(struct genl_family *family) err = genl_validate_assign_mc_groups(family); if (err) - goto errout_locked; + goto errout_free; list_add_tail(&family->family_list, genl_family_chain(family->id)); genl_unlock_all(); @@ -417,6 +417,8 @@ int __genl_register_family(struct genl_family *family) return 0; +errout_free: + kfree(family->attrbuf); errout_locked: genl_unlock_all(); errout: |