Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2654795pxa; Mon, 17 Aug 2020 15:38:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLjDlNX1GU0nvm8xwIEj4dArI/2jQsvInZnSoGYwjmRpuKaRhSUHSXh5Qi50w+SDQ0MyZj X-Received: by 2002:a50:fd0b:: with SMTP id i11mr16627790eds.298.1597703900963; Mon, 17 Aug 2020 15:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703900; cv=none; d=google.com; s=arc-20160816; b=reym7F9mt0zXoy0QSpCe07ooF4O5IcjEDu4HkaQEboj8Cki9omb4FbZ3H7eKAgN8sW OtReSwuLesqOn8nYTAkkdmt/j8oRsxliqx4L0RTMt1K+HFwe7skTYjecok5hqcKLVDXg RMt1Y6LFMfiH6Pwtzo13x7bkHOayt7aApwnspgnH7MJ66FY53wHEr1cmf9Z5h5GZ6YMu iG8fDkFd78Toai57qCgMudMUA4TK5saFKDlmy+PlDGbQ6GkIITNFAhFwb6CY8qGl0W5J cLtGV9n4UW5V5qq/zfwKqgH+QcbUVvmbO64LRcEVysEfMZ7Ql3YtRchYCoTDFSxhppsT zzLw== 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=zOJHvW2ldvahemimTGxp5q0zSRVESFWulqcyAXh1O1w=; b=0uPP5dEoadqsTUwyKLvYbsAM1mD9QesHHV3od1LTq1FBz0WHczB2MS/ix065HAntd2 I51vZ05iWsuiN4sioJoJ42wlh//hY/9jPgajZy9QZkFLHEcPymTaSlX6tqBRJOrOyYFd ZJKpm1tlwusG7Bf1GhMFhGpGW9UTV8CR3HQ29PTK1wSXRGPpnU1lW1XU0pMXkZmWZ6gf YE2axxtWUhwosftW1qzy4jT1s7CmkHCB2KFM8KyZjLxA2HlSIlZxOlzbFZjeOJIZ4bIm cpjw8Dqb1EMJzYcQKoiREvEdd0Z3Bug/mifHGtt/KzO2XlNkwuvrVbUvVOH/uIKbGnPn yQ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PLsm5JXg; 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 t22si11914920ejy.466.2020.08.17.15.37.57; Mon, 17 Aug 2020 15:38:20 -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=PLsm5JXg; 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 S2389327AbgHQRou (ORCPT + 99 others); Mon, 17 Aug 2020 13:44:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:51668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730934AbgHQQOn (ORCPT ); Mon, 17 Aug 2020 12:14:43 -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 C609E20657; Mon, 17 Aug 2020 16:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680882; bh=zVij81NjO9OlNZQfJq475tkpwu9Yi7VSo5asPkcp50U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLsm5JXgmZ6Ce01LwralGrlILRGhGR1m16nArrizBvCC1F9kXLtM3SKSgZPUDTgCs /iE7rpaFBZB+XqiL7P/TEfOddYhVLianYzCppOgbXE8uneTwTMEeyM5MMVPe71nmBi fdK+OBImChAc7TWtLfVKhWxtD6WgM6n3BkrFmwXc= 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 4.19 068/168] cxl: Fix kobject memleak Date: Mon, 17 Aug 2020 17:16:39 +0200 Message-Id: <20200817143737.123347684@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@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 629e2e1564124..0baa229d2b7d4 100644 --- a/drivers/misc/cxl/sysfs.c +++ b/drivers/misc/cxl/sysfs.c @@ -628,7 +628,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