Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp557161ybm; Thu, 28 May 2020 09:20:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwbXgSIHhs+AGzIcyssQq4QNxdTml5fZdOReMXBpiwa282agTTt7W4ZkmZ50m2WnLG4DRQ X-Received: by 2002:aa7:d35a:: with SMTP id m26mr3957897edr.25.1590682842725; Thu, 28 May 2020 09:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590682842; cv=none; d=google.com; s=arc-20160816; b=t8ellRDiPgFto8VH7vBOvg6+u5nEHIA6y6OizAjCQxNW/AubBQgKVeVSgfk+p6XifA 2ofYsYFtq0zfGKz4p1cRbb4/GL6A9N9F6xnGpC/R5vbP2CDgN4XO5rmpxRsccG7Zkmb3 g4UYTTQfcW1XRiqpM4ZWSesyJjNkP9XDPhpRXeQYC/Gal3JNWlLp1YkrCbHgGag2vXOe s3PRXabBaz+8g70s9YUm31kmz4XX3Ccw0lIZDRhZsisNc7ulgd5ihlhLKDWpuDZL5VoL 6Z7xHFdiJlpcgubNTb9vNYSmNkgiPNbWBmrdcydVMLc+rQXo8D2QLszvGpuWhmQDmuFP Xdgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:comments:references:in-reply-to:subject:cc :to:from; bh=YAtBLG0v1oiqPxxm5u4amjIlewq4Rp0y3s5mNsJbxB0=; b=A9sCCUWpysfrna8rRSnPsuBeDndyIL5i8iu1xacifwoVT+AItpGskrlY/Av3iB/oAo GBKT6zrJLGxUEUFQLwf9ZoDADQ3QokzMrAJG/CTPcUGGZ4AwrlT9ebKWVbm4osiyQvhW B5hUvYPo5tJiDrexwOi/pAyPpBy5IfMzLUc9NqC4Sa0KItO0PFrqlIHDzak67KuptzBV FKWfHl3TzvLHsQs4qQBsX9OJnatap8bvlm8+pytNyCWVeM7aLfr2tKdQx0DIaWrEEt3V zOqcU2nQqLFKu5TXR5ywbjvaK9itoqm7rBaEhyOtgNlKxSg+HFg30XbeiQPGongWN7up vK9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si4156242ejb.670.2020.05.28.09.20.19; Thu, 28 May 2020 09:20:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404977AbgE1QSU convert rfc822-to-8bit (ORCPT + 99 others); Thu, 28 May 2020 12:18:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:33171 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404830AbgE1QSS (ORCPT ); Thu, 28 May 2020 12:18:18 -0400 Received: from 1.general.jvosburgh.us.vpn ([10.172.68.206] helo=famine.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jeLER-00083j-MH; Thu, 28 May 2020 16:18:12 +0000 Received: by famine.localdomain (Postfix, from userid 1000) id D800E5FEE8; Thu, 28 May 2020 09:18:09 -0700 (PDT) Received: from famine (localhost [127.0.0.1]) by famine.localdomain (Postfix) with ESMTP id D082F9F851; Thu, 28 May 2020 09:18:09 -0700 (PDT) From: Jay Vosburgh To: wu000273@umn.edu cc: kjlu@umn.edu, Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , "sfeldma@cumulusnetworks.com" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add. In-reply-to: <20200528031029.11078-1-wu000273@umn.edu> References: <20200528031029.11078-1-wu000273@umn.edu> Comments: In-reply-to wu000273@umn.edu message dated "Wed, 27 May 2020 22:10:29 -0500." X-Mailer: MH-E 8.6+git; nmh 1.6; GNU Emacs 27.0.50 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2425.1590682689.1@famine> Content-Transfer-Encoding: 8BIT Date: Thu, 28 May 2020 09:18:09 -0700 Message-ID: <2426.1590682689@famine> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wu000273@umn.edu wrote: >From: Qiushi Wu > >kobject_init_and_add() takes reference even when it fails. >If this function returns an error, kobject_put() must be called to >properly clean up the memory associated with the object. Previous >commit "b8eb718348b8" fixed a similar problem. > >Fixes: 07699f9a7c8d ("bonding: add sysfs /slave dir for bond slave devices.") >Signed-off-by: Qiushi Wu Acked-by: Jay Vosburgh >--- > drivers/net/bonding/bond_sysfs_slave.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c >index 007481557191..9b8346638f69 100644 >--- a/drivers/net/bonding/bond_sysfs_slave.c >+++ b/drivers/net/bonding/bond_sysfs_slave.c >@@ -149,8 +149,10 @@ int bond_sysfs_slave_add(struct slave *slave) > > err = kobject_init_and_add(&slave->kobj, &slave_ktype, > &(slave->dev->dev.kobj), "bonding_slave"); >- if (err) >+ if (err) { >+ kobject_put(&slave->kobj); > return err; >+ } > > for (a = slave_attrs; *a; ++a) { > err = sysfs_create_file(&slave->kobj, &((*a)->attr)); >-- >2.17.1 >