Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5106284yba; Wed, 8 May 2019 08:00:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZz0zkj7pqnidVXxKlYymqb8ywUIGxtKHj19ut0X7zsS1nhSjQZ9HqHib0G+oFnJhv/oFJ X-Received: by 2002:a63:534f:: with SMTP id t15mr48182841pgl.445.1557327655429; Wed, 08 May 2019 08:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557327655; cv=none; d=google.com; s=arc-20160816; b=eYDB20ryxHIlrrxLFKDZvEqZ0rn1GGrqVytx3XiR4XaPyrGSgon+UCkXdwDN572mJu rrUhIdGnSDi/PStFdo3N5aAAjT80r0a6JT3B0Q2lLtMYADo3ZRjORjdRAQYeovTlxWGa 2VL1ddVDiJxonuO6qTpzWnm6LdRHT3sNdHcGVLxzwD21yvyhkI7LkfozzV/ogu7DwaAB KmPUQuyZoaXvDcI3/e1SxauxFGfol+MhI11MR7MGohiOr+MVBF8nZ/78Ew1i/ZICp+BI 0DZAw6sIKazbb9Wfb8dwUGQhhUz3ETIEROmRJwlf6/W+oAgUh7gaNGDkl+sjY94nnBAE a3LA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=xVx0qtoHyrcudlKtQn4Oq8tuwzPc5bXtNCZHPiLl7to=; b=r81jHXLZzCBZv9aZO9+//ZLNq6PxkAwLKzXs4R8DUJIr6if958KtgRpN+ziubpIkHE 0w4IH+8HILOWB8S1WI/MWpWZrZcuV77tbKsG9pdECwiHZA/WV8oDBZ9oe6x+OPJIp9Ne QEa0Jx85CjHBF5OuqNDNC8FDWO5KCVneqKpBwI3/qfzZCAYSQnAZohGiVxD6LwoJ6ivs OqqgGo6bcA/w78VSSYxP15zDt0/QAivadFPFeCr7QViRWnzELzE5GPmM8CxvuTJdfLMd eR631S9nftio6sYYmDyANJt6qMOGTPIGRSioksZosxHzxgMBIGcHd30gkVbWwdOlzAc9 4zFA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59si8152489plb.227.2019.05.08.08.00.37; Wed, 08 May 2019 08:00:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbfEHO7e (ORCPT + 99 others); Wed, 8 May 2019 10:59:34 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:32920 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726543AbfEHO7e (ORCPT ); Wed, 8 May 2019 10:59:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E4DE4F78B63A55120F8E; Wed, 8 May 2019 22:59:29 +0800 (CST) Received: from [127.0.0.1] (10.184.227.228) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 8 May 2019 22:59:21 +0800 Subject: Re: [PATCH 3/3] net-sysfs: Fix error path for kobject_init_and_add() To: Andy Shevchenko , "Tobin C. Harding" CC: "David S. Miller" , Greg Kroah-Hartman , Tyler Hicks , "Ido Schimmel" , Alexander Duyck , Florian Fainelli , YueHaibing , Amritha Nambiar , Dmitry Torokhov , , References: <20190430002817.10785-1-tobin@kernel.org> <20190430002817.10785-4-tobin@kernel.org> <20190430161124.GM9224@smile.fi.intel.com> From: "wanghai (M)" Message-ID: <2062f0d4-e51f-106e-cd0b-f0464d06f517@huawei.com> Date: Wed, 8 May 2019 22:52:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <20190430161124.GM9224@smile.fi.intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.184.227.228] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2019/5/1 0:11, Andy Shevchenko 写道: > On Tue, Apr 30, 2019 at 10:28:17AM +1000, Tobin C. Harding wrote: >> Currently error return from kobject_init_and_add() is not followed by a >> call to kobject_put(). This means there is a memory leak. >> >> Add call to kobject_put() in error path of kobject_init_and_add(). > It's not obvious to me if this will help to fix what is stated in the > (reverted) commit 6b70fc94afd1 ("net-sysfs: Fix memory leak in > netdev_register_kobject")? > > If so, perhaps we need to tell syzkaller guys about this. Thanks for reminding. It seems that the bug has not been completely fixed. in netdev_register_kobject(): 1746         error = device_add(dev); 1747         if (error) 1748                 return error; 1749 1750         error = register_queue_kobjects(ndev); 1751         if (error) { 1752                 device_del(dev); 1753                 return error; 1754         } This only fixes a memory leak after a failure in register_queue_kobjects(). If device_add() fails, kobject_put() still cann't be called, and the memory leak still exists.