Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3997107pxv; Mon, 28 Jun 2021 18:55:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHEMn5DTDebNTvtaFLRI85F+guwmtRpkYe/TmFcaHwmtLkwLl8hZ4dYeUI6BP9xFfbTAfm X-Received: by 2002:a92:2c0a:: with SMTP id t10mr20869703ile.25.1624931732824; Mon, 28 Jun 2021 18:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624931732; cv=none; d=google.com; s=arc-20160816; b=Ux9QCeG3f4PyBa7cXduBFVJr35Khkoi9pBg/EO+abbPS2YQ51O3naYjI6sf0hGlyw+ Nq1CCU0kAOOX8r72yBXSBOxj5uH2FsJQ9+KdDx1/p1eIiQNNUnCbNS9MSy93sKhtRAM3 oNYnuk8d6NnJfCION/Z51xKrUZQDBCXO3yB/2SgGMmggB19MF2Sg0nfB7DHcoIwowb76 Abicig0Dm/PMUf0hmUbPzuxt0FRhAUEML9dgZadzutFYlAhYZlFqlqUmJzPKnN5sqyAH 0ApZgqTAnOkFWdTmxpMfR8X4ha+r5mwFIq3rNzn0/76k0NWpAbY5CRGJtjZ0zAtu9kDA fmAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=V3a29uwpZPynWviwn+wXLXDgur/CodqrCIfVa2uk8rY=; b=FARbdfRfvCiVuLCQ5/gz6YVdfKdN49d9rhXOQuAwA2DrnOaAa2IL+oCtRNMKFqRCwc LZ7EpHOVAA54KXGF6gRJNXxF9kIIr0f5aoAtzx4DC+Qoghh4vXMFwK5DD8ICXGYgOHl3 mV30F3PdpkdmTVxe5WuJl9CEkdi/U6ASlu5OMEAUK1nllF0nOVDkNGafS47Rg+3EQQ94 nLvTUUI794PCddYYxeHz/LsgSqN7c9cm5SUs1GzIt6PLjgZVPL0DZRG/Z1Ob93jUgtuF SXY2l0ko68DWPq+VYhILwEdbRG5RiimsMdiYpYFIGeW7cYpcB5FSKnvmAX4gjE06O84j zZ2w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i36si7036182jav.2.2021.06.28.18.55.20; Mon, 28 Jun 2021 18:55:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231806AbhF2B5Q (ORCPT + 99 others); Mon, 28 Jun 2021 21:57:16 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:9314 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbhF2B5B (ORCPT ); Mon, 28 Jun 2021 21:57:01 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GDS962375z733k; Tue, 29 Jun 2021 09:50:18 +0800 (CST) Received: from dggpemm000001.china.huawei.com (7.185.36.245) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 29 Jun 2021 09:54:30 +0800 Received: from huawei.com (10.175.113.32) by dggpemm000001.china.huawei.com (7.185.36.245) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 29 Jun 2021 09:54:30 +0800 From: Nanyong Sun To: CC: , , , Subject: [PATCH 5/6] nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group Date: Tue, 29 Jun 2021 10:25:55 +0800 Message-ID: <20210629022556.3985106-6-sunnanyong@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20210629022556.3985106-1-sunnanyong@huawei.com> References: <20210629022556.3985106-1-sunnanyong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm000001.china.huawei.com (7.185.36.245) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If kobject_init_and_add returns with error, kobject_put() is needed here to avoid memory leak, because kobject_init_and_add may return error without freeing the memory associated with the kobject it allocated. Signed-off-by: Nanyong Sun --- fs/nilfs2/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index d989e6500bd7..5ba87573ad3b 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -195,9 +195,9 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root) } if (err) - return err; + kobject_put(&root->snapshot_kobj); - return 0; + return err; } void nilfs_sysfs_delete_snapshot_group(struct nilfs_root *root) -- 2.18.0.huawei.25