From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [net-next][PATCH] net/ipv4: fix a net leak Date: Wed, 24 Oct 2018 09:02:15 -0600 Message-ID: <92af7409-6154-eb85-7d2f-56f5288b8894@gmail.com> References: <1540373788-15078-1-git-send-email-lirongqing@baidu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Li RongQing , netdev@vger.kernel.org Return-path: Received: from mail-pl1-f193.google.com ([209.85.214.193]:40184 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726433AbeJXXao (ORCPT ); Wed, 24 Oct 2018 19:30:44 -0400 Received: by mail-pl1-f193.google.com with SMTP id b9-v6so2035526pls.7 for ; Wed, 24 Oct 2018 08:02:17 -0700 (PDT) In-Reply-To: <1540373788-15078-1-git-send-email-lirongqing@baidu.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/24/18 3:36 AM, Li RongQing wrote: > put net when input a invalid ifindex, otherwise it will be leaked > > Fixes: 5fcd266a9f64("net/ipv4: Add support for dumping addresses for a specific device") > Cc: David Ahern > Signed-off-by: Zhang Yu > Signed-off-by: Li RongQing > --- > net/ipv4/devinet.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c > index 63d5b58fbfdb..fd0c5a47e742 100644 > --- a/net/ipv4/devinet.c > +++ b/net/ipv4/devinet.c > @@ -1775,8 +1775,10 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) > > if (fillargs.ifindex) { > dev = __dev_get_by_index(tgt_net, fillargs.ifindex); > - if (!dev) > + if (!dev) { > + put_net(tgt_net); > return -ENODEV; > + } > > in_dev = __in_dev_get_rtnl(dev); > if (in_dev) { > Good catch. IPv6 has the same problem. Will fix that one. Reviewed-by: David Ahern