Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp562173img; Fri, 22 Mar 2019 04:04:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+CNNYZ7wfdbOnYCT4eBbR7I4hY61TPjBzQagppE12dnJMWG3luDiMbORSMI99IZ/JFjy4 X-Received: by 2002:a17:902:f01:: with SMTP id 1mr8776195ply.41.1553252691725; Fri, 22 Mar 2019 04:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553252691; cv=none; d=google.com; s=arc-20160816; b=DVic1yO4wpw9MpeHomiz1gRlqCuqx59tA4siY89I5rkg3DHVp9AG1tkEeK2YDaNB9w nPCXgOqygCb5n6ifmzHawghJK3jjt8YwFw+IF3bUWn+ETu1y/04FqSlC8IQ7egN+GUme A2/CqzJCK+thO8Nm2tMVqJqptRzEnBlSO7vqiL1/Tt0RSduo09ifm3ysaf9Yo0VuEs49 xPlIdQh0jGBFodsD26XUj+cSrma1gf8KVbUngcgmwVHuc2u5ZS3t16ki/Rrqv5GySCx8 +MO9xPlhig7NJSq5Ye3n4wP6LNU4GZdi2/1LwmHddAQssECANy83/nkybrcBq3s04rMY 3yAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=tARnFqnDLoNiyJz4d1wHFuzP0fBSP4tswfSsPoEBD/I=; b=1JoQfKDOHE5xc0vEheXB/6ScKYkaIKpFt4vAeBSVvcF2hHiYVSSlUB021DVyXpymy1 30QtVazuc23B11TFdGAtKwKyxa7mqZGyWrHoViovLhsN2mkh3W+/yQppBd4NpnjIDZXc n7qEHWyl/id8oA40MDDc8ZmggGaYrrfU2qEe0H+oV50OpYYZ454rc2Bw85mUzK/ancIE 5/wUq9IymCWZCT83bkMj66Wtr+TYi47QpD+RN3l+GYT2fxk5a6ffXQbCRDXVWESUeTwi AElK/rAhE9oAkTOc+bxq7amSf0mdMmGIBbsnGy9gQP9nM87Cq4n59a1hh7A65AzmwH0N M9lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127si6709102pfb.213.2019.03.22.04.04.36; Fri, 22 Mar 2019 04:04:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728102AbfCVLEA (ORCPT + 99 others); Fri, 22 Mar 2019 07:04:00 -0400 Received: from relay.sw.ru ([185.231.240.75]:34636 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727713AbfCVLD7 (ORCPT ); Fri, 22 Mar 2019 07:03:59 -0400 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1h7Hxq-0000lf-FV; Fri, 22 Mar 2019 14:03:54 +0300 Subject: Re: [PATCH net] netlink: fix a memory leak on error path To: Chengguang Xu , davem@davemloft.net Cc: keescook@chromium.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190322105845.25046-1-cgxu519@gmx.com> From: Kirill Tkhai Message-ID: <2acfd376-7b25-5eeb-2770-413b880bd4d9@virtuozzo.com> Date: Fri, 22 Mar 2019 14:03:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190322105845.25046-1-cgxu519@gmx.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Chengguang, On 22.03.2019 13:58, Chengguang Xu wrote: > 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 have you seen https://patchwork.ozlabs.org/patch/1059834/ ? Kirill > --- > 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 >