genetlink: Fix a memory leak on error path
authorYueHaibing <yuehaibing@huawei.com>
Thu, 21 Mar 2019 07:02:50 +0000 (15:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2019 04:26:15 +0000 (06:26 +0200)
commit9b8ef421b481d6e648438131d867986c649c297c
treea29c64a83c8be2e7f8e03d2ce7c11f6e444e6f1d
parent321461f2497fbb07b77edd2c184cfa624573b96a
genetlink: Fix a memory leak on error path

[ Upstream commit ceabee6c59943bdd5e1da1a6a20dc7ee5f8113a2 ]

In genl_register_family(), when idr_alloc() fails,
we forget to free the memory we possibly allocate for
family->attrbuf.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netlink/genetlink.c