Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1244926ybg; Tue, 2 Jun 2020 05:12:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoNHxzN62zdfuYgbgoMQorXXa/JIndDy7qXHntM89OeXYfPGVsu2EUWSYimE4sqUwaltGe X-Received: by 2002:a05:6402:1ca2:: with SMTP id cz2mr11762233edb.15.1591099966767; Tue, 02 Jun 2020 05:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591099966; cv=none; d=google.com; s=arc-20160816; b=XSefUkY6h6P7l9jjibIZVWJnYp9ozi38uxllSPoHzk0eqQEr/lUVynjpyVAsVhQhPO 2AaYRn4F7FH+/8TR2rTmGY76VkIxacyM8TGBYQtz8Ts4yb0LG3cmZKUorp0GwXgr6kGZ DPIGSsyKhmqM3Rj8IIXlKkCQv3PZrHMkzzBPFu96U8Yj+gbRGr3+5PxpUDM1ZLTlmJDg jX/iTxbE1NnDPwerOUQfU3aM9EK7JhXC1DEC/5o1V6D+IwsIsJQ2u+2Nacmf3LV5dv1g oaWVyz3A9vmWq91UIjMTpuur+MD79QRjuA8Hl1HP0rAblhM1ETCZTJAPVcceilc8aw1J B4aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=MPWVgQL/gTxIpik0NsWG3ZmAe9YX2s4Yc5caQkAGp0k=; b=gXcaa7bJc2vauxPSWtT7RA41f5rRWc29nQwD5aYRBAPzRCek1rKa/DSpurqFmHxzE+ yNtnwIRd11BbMRWJkZn7lNazZ6N65MiJ8lzqJ/hDeUfOStafbPDijGwvcVTNF5Mjuxk/ CPJWUjmzSeWHftEw6qmfUemAjN2DBlKr13cpp99sNzNUAMxS+WOqtzbVkqbWvwU/4MUO dzLpdbL1Asl8NUB5k+JlU0TUsqwxpw8bRIeRB8dUnsecbyPMt7N5GeXhGfsdJZ4MxV3J mQHY7xNBdAqxZtZ7aVbxodVhopUSJt99TiYA/BC1Ly3OO4vbgxWv9R2fp1+3Dfoye1IB nAoA== ARC-Authentication-Results: i=1; mx.google.com; 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 ci2si430895ejc.191.2020.06.02.05.12.23; Tue, 02 Jun 2020 05:12:46 -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; 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 S1726380AbgFBMIC (ORCPT + 99 others); Tue, 2 Jun 2020 08:08:02 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:40014 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725919AbgFBMIB (ORCPT ); Tue, 2 Jun 2020 08:08:01 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 725333EECE82EA8BDB1B; Tue, 2 Jun 2020 20:07:59 +0800 (CST) Received: from huawei.com (10.175.113.133) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 2 Jun 2020 20:07:52 +0800 From: Wang Hai To: , , , CC: , , , , Subject: [PATCH] cxl: Fix kobject memleak Date: Tue, 2 Jun 2020 20:07:33 +0800 Message-ID: <20200602120733.5943-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.133] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 f0263d1..d97a243 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) -- 1.8.3.1