Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2630898pxa; Mon, 17 Aug 2020 14:56:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFeDpuMR7+tLBkzfCLbYx3c9VbmFwBm49SqYRkCxhrn+plXqW5qCWuTEuUCFRBn0yO6jui X-Received: by 2002:aa7:d758:: with SMTP id a24mr17485935eds.379.1597701400599; Mon, 17 Aug 2020 14:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701400; cv=none; d=google.com; s=arc-20160816; b=UvhxFMXIb3syAParogTSZG2P+7yZfw0QdYD36EwPAMexUJ/CQynyCGgnn14UY8BpS9 rqLN4YPW4yqPighntx9sJ1k6F6PiTdzBrfxW95T5zepvp+z5gwo3Kek3Jz7/APA/PCXI Fh3gusSgUKAhSS/6Tojhk5Fik7qRERwEF8/Y9iOGK5+wpUdKaomae7WZy8ps807HXYhz VuCT4WCwUbuDLi7T6OJd87Bvvi6eJ0Khw2MniHIYBpsWURKfPyMjwdTk8hqJKBDpfDM5 KyEHYr30/ZdYQLSePL09iYOWJRi7fDduDxYHa20d2c8adaRqs8IYcXB9/aCh3Ft0EUoi IMtw== 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=SzY/LGUuf611AoWeaGgHyW7HVKaESB0vBHq0dCkl0Lg=; b=eptbMCqCbVdNPp9rOIcEyAcuWSwYdFWqUVS4SFMQxUOW63MgVZpnM/Xbyo3X8cI1Os YL0csEY8Y1KVTqQLb9xCJEr9blGX5U1odkO1FocKgpICLdc54oepkQ2GZScdoAqSca7L Q9A2vc97s00mYbxgtNmJKtpCboNyfyzUVCzoKhTYgi0klcLBVbboytPHaegwFF24Wkn+ hX5tLOKtFnGV0GnxiN24wrbrxgfBE1CCiuUQAT4iCZUSAy9gpqxytR/ncHPuZZLogM+k kpJ1I0eRNy4sI/3+qSlU4sQmJ0mHgh97N+eAJBsymw6nvXfEMqWYxUND9N7VinLE0ks4 bNmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qAW545Eo; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si12064702ejz.217.2020.08.17.14.56.17; Mon, 17 Aug 2020 14:56: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=@kernel.org header.s=default header.b=qAW545Eo; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730127AbgHQP3n (ORCPT + 99 others); Mon, 17 Aug 2020 11:29:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:39868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729924AbgHQP1g (ORCPT ); Mon, 17 Aug 2020 11:27:36 -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 DA8D8233CF; Mon, 17 Aug 2020 15:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678056; bh=u6wmnyOOZXtqwxDGaWRzoJFsFE7VNtRuFcd3L5HmiBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAW545Eoe/ytO6yawRJ0VqgiKpQoRXZsOtoR2TJBwapVg4A42UjmpptV64C5ItZOm 9JL2OK8ezNft2ImdGbplp865XGqOjfi/y1sl7dn4O79mkuGy+AESDWSObxPZTYBjh2 gdo38SVG4irfSm5p+d7b3cCRbZiZS98OR7hl67Fc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , Andrew Donnellan , Frederic Barrat , Sasha Levin Subject: [PATCH 5.8 186/464] cxl: Fix kobject memleak Date: Mon, 17 Aug 2020 17:12:19 +0200 Message-Id: <20200817143842.731796077@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@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: Wang Hai [ Upstream commit 85c5cbeba8f4fb28e6b9bfb3e467718385f78f76 ] Currently the error return path from kobject_init_and_add() is not followed by a call to kobject_put() - which means we are leaking the kobject. Fix it by adding a call to kobject_put() in the error path of kobject_init_and_add(). Fixes: b087e6190ddc ("cxl: Export optional AFU configuration record in sysfs") Reported-by: Hulk Robot Signed-off-by: Wang Hai Acked-by: Andrew Donnellan Acked-by: Frederic Barrat Link: https://lore.kernel.org/r/20200602120733.5943-1-wanghai38@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/cxl/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c index f0263d1a1fdf2..d97a243ad30c0 100644 --- a/drivers/misc/cxl/sysfs.c +++ b/drivers/misc/cxl/sysfs.c @@ -624,7 +624,7 @@ static struct afu_config_record *cxl_sysfs_afu_new_cr(struct cxl_afu *afu, int c rc = kobject_init_and_add(&cr->kobj, &afu_config_record_type, &afu->dev.kobj, "cr%i", cr->cr); if (rc) - goto err; + goto err1; rc = sysfs_create_bin_file(&cr->kobj, &cr->config_attr); if (rc) -- 2.25.1