Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2641277pxa; Mon, 17 Aug 2020 15:13:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsjutyAe6ARWE9Olgp+peZOH8hs0pQWsnlTGz/PEL+ka5WOXO3fVByWqM+MPeAxXgLkTF8 X-Received: by 2002:aa7:d515:: with SMTP id y21mr16552256edq.381.1597702436824; Mon, 17 Aug 2020 15:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597702436; cv=none; d=google.com; s=arc-20160816; b=tyLAjaiXMiUTCFsI1w3N252ivw0TrlRHSo+RcLHl/n5wU6opTCIVk9QEdDL7N4+Ceg 1vb+sc/vN9dijDM+AT2tY7WAXdb20w4PjwAPwURl28S9ihIyLAGMtip9UuJSXz9+Q6VM SqdI4OriHEAUzDNL38OdQTCGwstmxEFtWop7pg7QkLv7Y4OdMB0tMlYTUHQtQ1n2bw4L irVV0agZ9r3fXNFhzndyJkxC1+IqWKCkNg5YxSRz/wI7/8bc+1P/h84JFuI4OGiOhKRL 96jHbh4a4ER4+LkcH0CcW39WPjK2HTwX38k61X736zfJ2q6bSDFvRjlaBZ96kz3JUV3W +VHQ== 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=ISjRy3ndlDDPwpSEZzR+80zL+8Xcz6unxaLbwL1My/Tmkjsa3N65S5MS7DIDpm+N8r +fsK6I5jgzEd/0hl3Ze1xBaxurPaSZPhxeduV6hclrY8jr3cijIgbYCm+wvdRjIkwfWR KcI1CjMHZWSdW2+1L6xymW0xi3JEf0oXtlwwuc80uejAJEusHo8ofj/CLO1ZLUDexVFe ct37o4Cr/z7nsTMe7esVYaKJkPiGG6dbKgu5kM/cKDQ3j4oJYu4H6MpU+nH4XN28PuN/ Ejl1UXWPqX0wZBV94P2zgWnO7m+IQt2EDtS+x9LIwKnOVsuYw7HTN2s0rGn86ELSDSB0 vJCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Zo5L7UBD; 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 r10si11664819eds.138.2020.08.17.15.13.33; Mon, 17 Aug 2020 15:13:56 -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=Zo5L7UBD; 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 S2389046AbgHQQ4e (ORCPT + 99 others); Mon, 17 Aug 2020 12:56:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388295AbgHQQEW (ORCPT ); Mon, 17 Aug 2020 12:04:22 -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 EE17420866; Mon, 17 Aug 2020 16:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680260; bh=u6wmnyOOZXtqwxDGaWRzoJFsFE7VNtRuFcd3L5HmiBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zo5L7UBDGUZ9zNHURXN+AtFqwheNcSnO4enKQ6kgtshpokElUUAXVZnRcNxuzqFml wRba6J1+g9YZmdYQHyKfiOKLvC+vdoHJtG3qe8eHRe+PiFSueel3n8YEgHw6hNM024 W9WZaYUfK3i2ybkng5OSEHi/yBzWhxdNtODFZH98= 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.4 115/270] cxl: Fix kobject memleak Date: Mon, 17 Aug 2020 17:15:16 +0200 Message-Id: <20200817143801.501830168@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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