[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b722948-bbca-327e-d5c9-989f0d78cf6c@virtuozzo.com>
Date: Thu, 21 Mar 2019 12:26:50 +0300
From: Kirill Tkhai <ktkhai@...tuozzo.com>
To: Yue Haibing <yuehaibing@...wei.com>, davem@...emloft.net,
keescook@...omium.org
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH] genetlink: Fix a memory leak on error path
On 21.03.2019 10:02, Yue Haibing wrote:
> From: YueHaibing <yuehaibing@...wei.com>
>
> 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@...wei.com>
> Fixes: 2ae0f17df1cd ("genetlink: use idr to track families")
> Signed-off-by: YueHaibing <yuehaibing@...wei.com>
Reviewed-by: Kirill Tkhai <ktkhai@...tuozzo.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 25eeb6d..f0ec068 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();
>
Powered by blists - more mailing lists