Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5284486ybp; Mon, 7 Oct 2019 23:55:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaGE6kbj9cs/Pdf9gx8fSIulbNGRkb9IXXutOTfWeklfO1wNo6RjNRwWm7LePOcSVfJ+L8 X-Received: by 2002:aa7:d789:: with SMTP id s9mr3517308edq.62.1570517709592; Mon, 07 Oct 2019 23:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570517709; cv=none; d=google.com; s=arc-20160816; b=UNXG/AoHijsewVzwNTzoF+iykmqnK6RH4KpsZ0KqG1MBQBV4lwF9IT7xxf8A68/6NF fpfAu8Sw8DY/X8JC1xaJA6w0Fh+Xgjcr2PE4l4ge0coWsuHBMoTT1DXvpkozLQoS6jEs aNYooElICpK/TqpqYHSZFb5rLfeuXoz45ABL0Y4K5SihMjM7GiJgiwisT9l5OlTHqSeH n8c+UlNwwfp+vwSVgyMbDNx6Zu/n1+iTgOQpLPBp/GebiZqpI+rh7jJnEalqHf+Ra5Bw MU63vHZ6mEpo6JKdrjDqL1ZJeqrmBg71v/swXqTtDmiOqalaNG2ioZvVqRqtZIdKCIdG t+Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=zM3giIosfgoQWz0D3Ztxbeg2hJtXoytSuhU/8Ui29xY=; b=qLf+rXXjUr+Ddqj4Ktsjtb0XjMHX8UXWUdk6zrKabfNJvTCUuIBdsiXgL0/YnA1U/t 3X/aMpl0phkPsEy1PmSQAHo+HuL7RFSZsj5adLf7nIlwHjwh30ofh6F5mFxGbyr6IiIN 532QyQt+LgVvk/zjvxMncaHqIvpRxWiMhVMo/ojNg/EcT6/i26pcMiACHaXWfSE5G0ya PbBxu1JjzY3pGDtgUXY7QbKrkxmGhGz6sYwtbaCHtpLHXLz84WUYu/XzeLzDx88Ln8RB ZV+XQ8m9Wf6FBOThEA9fLUSrW1McMY9Gv2mAJdnVMz2n5JcFK/gn4UIz7hv2Y6fT7aHa kbuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hrClwW6b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e47si10316401ede.325.2019.10.07.23.54.35; Mon, 07 Oct 2019 23:55:09 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hrClwW6b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730150AbfJHGyD (ORCPT + 99 others); Tue, 8 Oct 2019 02:54:03 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38046 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730131AbfJHGyC (ORCPT ); Tue, 8 Oct 2019 02:54:02 -0400 Received: by mail-lj1-f196.google.com with SMTP id b20so16285098ljj.5; Mon, 07 Oct 2019 23:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zM3giIosfgoQWz0D3Ztxbeg2hJtXoytSuhU/8Ui29xY=; b=hrClwW6bQURhdQAdtLH3QQvaHEvRbRkhg/qVRZhJh4zfePeHy9qhIaDOwd48ZsdZAG OdzX5lGqK1+vkMZdPI/NPo+MLzxYopsGe+8KJztWeTMuD5Dm2ufz1qo0Nt4EXbNOBnrR mMADUBLd6FehdtNLMI3wX3FE0VfrHSmBI/8u76wT07nA+oZAllRMu3slGtsk+hbQhLSW FwgMhp+XGfJ+K4gy7ePFm5LifD/5L1lrujfsOV7MMQERj+jIdDmmzPOWwZu+iyNnqrF/ roTHdTdQ3lWR1dPvzsBr4gDd3dkzuV9yNDuCHhIiH7kMmGiMhkl0UqRB/5ZjRTDoenJY GVVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zM3giIosfgoQWz0D3Ztxbeg2hJtXoytSuhU/8Ui29xY=; b=b9KyKpFiH6S1VcRUGLEkYW8gHwBoAI8Uk1KVCf+F++NBBHslGwYHU1KmAwPSoU4qib ow3erWZCgFgnttNSPRzTIuoGqpdO1NNQJ/cQlzrUF+XW5oE/VQyTmsgoluYBpxz9ga2D LqGk5C979BY0KcC+5fRhQZreI3yZ5sVy8xMRxhus0FZHfypMHZ4okg+CilZd6cdJmRj+ Cc6s4k0Xnga2mECnDNWuZU/iqqTScbzqo9c0cw/dxWT4kTdGH9UIxaqR39JeD4Zggy0x ABgKd8WMm7eoOXL4zphU1GeGSeaq/hGQpamQ4J7b+TJKnepMXURanHTCdXdyeHeKNK43 mf6w== X-Gm-Message-State: APjAAAWR1rsh/Ia5XLtRR2YiGKSS8KivpXX3YlNwZG2rsku+kze3ghh1 d/yDRVt7yvtMExyofqQE4TT0r3mt5/HzzFmyBEA= X-Received: by 2002:a2e:1504:: with SMTP id s4mr12753917ljd.80.1570517639723; Mon, 07 Oct 2019 23:53:59 -0700 (PDT) MIME-Version: 1.0 References: <20190928164843.31800-1-ap420073@gmail.com> <20190928164843.31800-13-ap420073@gmail.com> <20191007112215.GA1288400@bistromath.localdomain> In-Reply-To: <20191007112215.GA1288400@bistromath.localdomain> From: Taehee Yoo Date: Tue, 8 Oct 2019 15:53:48 +0900 Message-ID: Subject: Re: [PATCH net v4 12/12] virt_wifi: fix refcnt leak in module exit routine To: Sabrina Dubroca Cc: David Miller , Netdev , linux-wireless@vger.kernel.org, Jakub Kicinski , Johannes Berg , j.vosburgh@gmail.com, vfalico@gmail.com, Andy Gospodarek , =?UTF-8?B?SmnFmcOtIFDDrXJrbw==?= , Roopa Prabhu , saeedm@mellanox.com, manishc@marvell.com, rahulv@marvell.com, kys@microsoft.com, haiyangz@microsoft.com, Stephen Hemminger , sashal@kernel.org, hare@suse.de, varun@chelsio.com, ubraun@linux.ibm.com, kgraul@linux.ibm.com, Jay Vosburgh , Cody Schuffelen , bjorn@mork.no Content-Type: text/plain; charset="UTF-8" Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, 7 Oct 2019 at 20:22, Sabrina Dubroca wrote: > Hi Sabrina, Thank you for the review! > 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 = ..."? > You're right, I will fix this in a v5 patch! Thanks! > Thanks. > > -- > Sabrina