Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp85942ybm; Wed, 27 May 2020 20:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn+QsQHZHVCnAyQerWyAA4GP+0Yz2q9nZfbBA1G8rBffXnfddnDiTZZjcyY2d2EgkxemRN X-Received: by 2002:a05:6402:68f:: with SMTP id f15mr1056788edy.89.1590635560545; Wed, 27 May 2020 20:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590635560; cv=none; d=google.com; s=arc-20160816; b=aIopX4kMXHmlUzETigceT8Px8MJr/3Ar4RXtQXHZj87tPUMaWzo1SDArk+IyN4kfmj fKfZa9QcxRdhdHLnoL9vjFDcjcR6oHWab71/UU6VwPaI46h0sGxUKGriU7WMCg07l1I3 jMtqOZ/u2GN4BPHAve+MkCZZBvI5MBHzWV5w99rSjwvKp5Sf/cQ0tcwGcEq/Tsc2lFcK i1DakhMhnJiOj087lOxPQO0Vfk7dPhaV+xXmQT4FMjGQcxBQX8lygTB0uN+8TdUlPCgv HfQ6Dtuabm99HG1Z4c2QzsfB/RooNFvD6JmNeHu1d+ycAFUII6oKFTMPd14FOdT6gqah hjUw== 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:subject:cc:to:from :dkim-signature:dkim-filter:dmarc-filter; bh=IHcaKYQFAiNpjDs/H7x5QNmUSskJMpHECApqwdRwTWM=; b=qSIoxvHiVmIP1OL5EnsDM5/aTy9D2TdhEE74au5Zf2RvctXxr2k3z0BuUge9hfIc04 J3LF966L9lYibPYXdVoUE4/sHV8e0G8fdRxlJnd715+Ox/wlwJI2ynVpN8KV3yxTsOVY tMC/UGwnsU7YyO7ryKHWRezepZ9kLAJWdp9hOQkRkJJ6Iq/fYJ0Avt6WaWtN8s5QpqJH 4zsZWr99V9b+lYkKZXdB3NZE55VNBcJqWStqCvtPbUAf8Bh4PjqEo2CWPAlQLFRddnlM cpA015DKuo21KnA7or98I0L8EYOX9Z9pbIr3Jhb8LN3KSa+HHAGnOh16WJiyu+WZ2nH8 kLow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=gvbMCp6G; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si2118550edx.535.2020.05.27.20.12.18; Wed, 27 May 2020 20:12:40 -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; dkim=pass header.i=@umn.edu header.s=google header.b=gvbMCp6G; 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=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726773AbgE1DKi (ORCPT + 99 others); Wed, 27 May 2020 23:10:38 -0400 Received: from mta-p5.oit.umn.edu ([134.84.196.205]:60366 "EHLO mta-p5.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbgE1DKi (ORCPT ); Wed, 27 May 2020 23:10:38 -0400 Received: from localhost (unknown [127.0.0.1]) by mta-p5.oit.umn.edu (Postfix) with ESMTP id 49XXl12ZsHz9vKlq for ; Thu, 28 May 2020 03:10:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p5.oit.umn.edu ([127.0.0.1]) by localhost (mta-p5.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p3Pf4uCmRNjp for ; Wed, 27 May 2020 22:10:37 -0500 (CDT) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p5.oit.umn.edu (Postfix) with ESMTPS id 49XXl10lMFz9vKbW for ; Wed, 27 May 2020 22:10:37 -0500 (CDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mta-p5.oit.umn.edu 49XXl10lMFz9vKbW DKIM-Filter: OpenDKIM Filter v2.11.0 mta-p5.oit.umn.edu 49XXl10lMFz9vKbW Received: by mail-io1-f70.google.com with SMTP id l204so3524800ioa.4 for ; Wed, 27 May 2020 20:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=IHcaKYQFAiNpjDs/H7x5QNmUSskJMpHECApqwdRwTWM=; b=gvbMCp6GIqQTfK/GiPhRiAmCDTkrNDaCfn8BnA/o0LRY3Wn260v7b4F4sHZ0kCKO34 6LAjdtdpWJWEIsivJtWDXm9raSVKWLKACHfTjZSdRb8IfZmUob9sQmmgYumjSTDiA8NL zrrYP5xb8+HnxfZo/N8a3JaYeJb9NhH94CZqSMTovLyI+RoNae3riAFD7b+0hGJzvoYU ndUvLIhQ5wi+jm6yiqzbdUxjEUFIgj779zul63p1GprJu6KwxlP85Lyq+5g2R6K8EiG4 ZuypldLfEQxx+2KfTBvGP+IakUO+HYeNXIdOmFVYXgb8LRZZfblBbSpk9lo5/8wP5+Af IGGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IHcaKYQFAiNpjDs/H7x5QNmUSskJMpHECApqwdRwTWM=; b=T9HWkPAUYRyjCoorvscnVi4GCL2wbnFSso4xbEKhjMIpoBZCL/XVXalkiPVKjX/iZk y8gJYGhmV13NDXcI3vDgqkz870OJ7A2WZWod0UOs9bMCYv8Z4eM2QVQFKDajIFZEW6Ys 6/e5kUF7gnKi8Wf5mCsDcVxEbnzzWLykGMJ4W8ld7G2j6GIz/m552n15QzZVrzFLdJf4 +7N1kNYsydyLG447KyHlzLaM2tYO83PA9VU8LQuqiOHhKLTvGw+YoMfg56kr38HCtfuv /xh1eIoe5R5qSUK27rgYUWGYSsjYFTFUMkeLFrbbxWkWomR4CYsgCDWssERQaVe3DWsr KsIQ== X-Gm-Message-State: AOAM530SIptuMiLQa1eRl3AbScHro8kcjeuujxb9HaiB/cJG+/yP/vXt DGWl/IKkzX2xoTMug/tUoAEjl6Ped5OFVBS12aSa7or+fhqmLkhdMIlN32fScTNPssepTyGfUPB Sx4uOMW8zH9qVnjCJ7oyDw0jBmqnk X-Received: by 2002:a05:6602:13c6:: with SMTP id o6mr748543iov.84.1590635436650; Wed, 27 May 2020 20:10:36 -0700 (PDT) X-Received: by 2002:a05:6602:13c6:: with SMTP id o6mr748526iov.84.1590635436342; Wed, 27 May 2020 20:10:36 -0700 (PDT) Received: from qiushi.dtc.umn.edu (cs-kh5248-02-umh.cs.umn.edu. [128.101.106.4]) by smtp.gmail.com with ESMTPSA id n8sm2008029ioo.2.2020.05.27.20.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 20:10:35 -0700 (PDT) From: wu000273@umn.edu To: kjlu@umn.edu Cc: wu000273@umn.edu, Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , "sfeldma@cumulusnetworks.com" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] bonding: Fix reference count leak in bond_sysfs_slave_add. Date: Wed, 27 May 2020 22:10:29 -0500 Message-Id: <20200528031029.11078-1-wu000273@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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