Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4167766ybp; Mon, 7 Oct 2019 04:26:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyudIbPJeNCxcahzZtJJmB4rpHZiNWGxNqafPNQ4GHrYCH58Yt+3AV4C15wPOTQVgp9LPo X-Received: by 2002:a05:6402:713:: with SMTP id w19mr28107744edx.126.1570447564305; Mon, 07 Oct 2019 04:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447564; cv=none; d=google.com; s=arc-20160816; b=rxPLO7gMxLK/LDp7sDTFuaSITX3bnp4wk+XJl1P7NZu9stMBhehl4vm6Fvv+LUoSzV w9QqTH95WM+v0+6OAVBKDtFJv3sVkhpEOAlBP5+33g4BcYQm21vyhcLCPNcYSt9crjXw aIQkW7WkkhG6CESeH2iG4awRp8IxpE5z7UgeNYq8dHjPOgXSsWm3UaytyuADz5or4Biy MDczDSDyt/Gz3Uy5qhXl1kH/En29oaX130OXm+upnEIu36m6QXCCNP70bHYAXgKA5IzB KebP9XQrGpvJQPAalRN3UhvdgXJWtuGRZR4I/tal+FqUbWe9j7sDsl221SU+DuRTAkkG VydA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zGuyh2GrKWCegCXoK/UVs7VptXFO2SAt31MIiJVBe94=; b=WkN0UMDoxbug7ytPrIS+nSK2ls5YcMXExJy9+f6FwmmxAoHY0BrWiaLWwOah2Y7o6s cffpil0SlPH1tQNYfS3Zno2QPvDgAInkl/OG/JHDjYJTWGNGS3DMJtuH8KiyLiSGOLR7 guU5w7j+bQ83kqUmo+Vz9eg4G1d7ghKGjHJF3lRKgZAG9JWclpcsSdeAq+8JeR8H+D2f oU+2kZDurcIDbB4lBSPpy7djrT90WtFT+2ExUB6EwUzNrtzwT6ASxnZorzLU5eNv+0ce GcG+7wq1XPeqXIGjwaLJKezeJULsTrG1J7M4Br1goWVmMTJzsA5GbVDDUcx7iDFpQsmF FpXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qx24si6804385ejb.138.2019.10.07.04.25.29; Mon, 07 Oct 2019 04:26:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727514AbfJGLWY (ORCPT + 99 others); Mon, 7 Oct 2019 07:22:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48368 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbfJGLWY (ORCPT ); Mon, 7 Oct 2019 07:22:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABC753086228; Mon, 7 Oct 2019 11:22:22 +0000 (UTC) Received: from bistromath.localdomain (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7275360606; Mon, 7 Oct 2019 11:22:17 +0000 (UTC) Date: Mon, 7 Oct 2019 13:22:15 +0200 From: Sabrina Dubroca To: Taehee Yoo Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, jakub.kicinski@netronome.com, johannes@sipsolutions.net, j.vosburgh@gmail.com, vfalico@gmail.com, andy@greyhouse.net, jiri@resnulli.us, roopa@cumulusnetworks.com, saeedm@mellanox.com, manishc@marvell.com, rahulv@marvell.com, kys@microsoft.com, haiyangz@microsoft.com, stephen@networkplumber.org, sashal@kernel.org, hare@suse.de, varun@chelsio.com, ubraun@linux.ibm.com, kgraul@linux.ibm.com, jay.vosburgh@canonical.com, schuffelen@google.com, bjorn@mork.no Subject: Re: [PATCH net v4 12/12] virt_wifi: fix refcnt leak in module exit routine Message-ID: <20191007112215.GA1288400@bistromath.localdomain> References: <20190928164843.31800-1-ap420073@gmail.com> <20190928164843.31800-13-ap420073@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190928164843.31800-13-ap420073@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 07 Oct 2019 11:22:23 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 2019-09-28, 16:48:43 +0000, Taehee Yoo wrote: > virt_wifi_newlink() calls netdev_upper_dev_link() and it internally > holds reference count of lower interface. > > Current code does not release a reference count of the lower interface > when the lower interface is being deleted. > So, reference count leaks occur. > > Test commands: > ip link add dummy0 type dummy > ip link add vw1 link dummy0 type virt_wifi There should also be "ip link del dummy0" in this reproducer, right? [...] > @@ -598,14 +634,24 @@ static int __init virt_wifi_init_module(void) > /* Guaranteed to be locallly-administered and not multicast. */ > eth_random_addr(fake_router_bssid); > > + err = register_netdevice_notifier(&virt_wifi_notifier); > + if (err) > + return err; > + Here err is 0. > common_wiphy = virt_wifi_make_wiphy(); > if (!common_wiphy) > - return -ENOMEM; > + goto notifier; err is still 0 when we jump... > err = rtnl_link_register(&virt_wifi_link_ops); > if (err) > - virt_wifi_destroy_wiphy(common_wiphy); > + goto destroy_wiphy; > > + return 0; > + > +destroy_wiphy: > + virt_wifi_destroy_wiphy(common_wiphy); > +notifier: > + unregister_netdevice_notifier(&virt_wifi_notifier); > return err; > } ... so now we return 0 on failure. Can you add an "err = -ENOMEM" before "common_wiphy = ..."? Thanks. -- Sabrina