Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp691160ybg; Mon, 1 Jun 2020 11:47:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMDnBRqF8bPbCEklycZgPNk+kiCESsm0v1JQNYnIEvN8q3mHywO/FK4T6Mq58nxAISPf5O X-Received: by 2002:a17:906:7f02:: with SMTP id d2mr5684401ejr.211.1591037277955; Mon, 01 Jun 2020 11:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591037277; cv=none; d=google.com; s=arc-20160816; b=ls92WYhrOGZhcdR21ZwHA2SSWy5xMej/xAlh0ouRjkIJeMliw2LVPOMo0rK7EaPvnm ajMTqtZFYxkK9Cui3KcDKdKLLg5rDZzxPH71EqrJKpnz+G0L4tToSv3/Q4lw5gaDkHPA s3U5paX1Sqlu6O0ErCuSMpRB0jPJ2iHLm/CvOD1p2Ktpq9RlkToQKl1TWyIJ6REGLhSU KanNShuGv7vxjXIyXI4NVdOQMN9yEz1ExtfEWUYwKCkOI2SdFD2Z1vak2icYuF5npAK9 p980IZhh1h/6p06bTi7N12CVWkZZW5rFvTqgTm1m25JH9PhPN+S8F+lM9/vdV5b9QmDL /xkA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qysgHSSY168vVr1JAJMBCkKJPCKbxVYatW4uW7N3ciI=; b=FHzWmR71SnPx7yi9HLYTbqnK12Xw5WevQTPQ7csH/Ue5f43SNAU/WL9nAgV/pWYaSP R2GQrblO2qKUGs8FLmPiK4PHqTN0bHCssE+wyFsEbzGGp94OIVxMtDzPuxLui+XQ12Oa 8Nygy75dkrJ4p+CUbGEckFJ6A+gTFgTz7bqwxYN65BcOZlGamgSzaLAw/nijv/I5iSBT l+u80VjTfaubCqaiM4kR9d8nXBb/YVAdA0PPfOb5HaeKCoE8Zs4ZR9eSj9/ike64A/So Eb6sjWNQXavrGYK+rUS/gLjVSXTKIt7Td0z+dOLB8iOyI5YUqaho6DlAxxxIHkCm4j33 UFzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IFKWDiV6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si122842eds.421.2020.06.01.11.47.35; Mon, 01 Jun 2020 11:47:57 -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=@kernel.org header.s=default header.b=IFKWDiV6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730024AbgFASnz (ORCPT + 99 others); Mon, 1 Jun 2020 14:43:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:58258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730552AbgFASLJ (ORCPT ); Mon, 1 Jun 2020 14:11:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A9724206E2; Mon, 1 Jun 2020 18:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591035069; bh=VJCgLwsSNHwLmsfHycjLYWKHAkmJNu9lyn4RGGguDvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFKWDiV6ffTZSV3xn9rfSBXjM45e1JaYzUL4QSVrN3uj2ryxBbMuEyaoD057hUMHM bSUYKHyrShihTDW/hFWWiHRPbdwNS7/Pe8oVoOfvT9WGB69t+0anZa9XumQL3M8U92 7sxGTSWPWNPlLVhqR16m4mVGo1BAmtPLQ+nrhst8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Jay Vosburgh , "David S. Miller" Subject: [PATCH 5.4 137/142] bonding: Fix reference count leak in bond_sysfs_slave_add. Date: Mon, 1 Jun 2020 19:54:55 +0200 Message-Id: <20200601174051.902277007@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174037.904070960@linuxfoundation.org> References: <20200601174037.904070960@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiushi Wu commit a068aab42258e25094bc2c159948d263ed7d7a77 upstream. 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/bonding/bond_sysfs_slave.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- 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 *s 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));