Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1718889pxb; Fri, 24 Sep 2021 10:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDZOGcd4nXCKNDpaht5kHasXecqBFz9My61TPaD7vbUI13ufSbK+NFz5R53CGocIc7M8R0 X-Received: by 2002:a05:6e02:1e03:: with SMTP id g3mr8201832ila.127.1632504016411; Fri, 24 Sep 2021 10:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632504016; cv=none; d=google.com; s=arc-20160816; b=rqh2mZ05Trrnuq6PJHEsTYRac7TvKz5eqw9U0MM8KehMKBA7w8fntyqhNbhkkq8qzP wrdAOtOo0O9seJh8AsOc/2YOM/bgkLwi3PphR3rJ0JoJKNRbNfvzytvoM3UWxJkcspyk 5RSPrX0J5PlDOjUMMwJgVWAXZAFwHxY1m2Wyuq5sIKr1TBTBhAcnbH0RD4cVOI8l3YZd KDiy/8/xp3yd+Ihp/wx5sb+C1HI3FDuFGssGso6IcxeIbekgg9geuZ5VTPou8ztemuni uUo3WaxRckmtW1Yy9JwPNOT4QxFPKBE+Lc+le5tCBLCJu0pCdBSxja3BsV9Ytf9s2+n8 tNpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2L5t1l+xj/Honz/YVqa1jILQ4tOBRjHzTN4J97weVxc=; b=eqs5gPYWSO6xsWzUK86umH5HdlLayAizsZ1JsfqXF6I3QhcMZKY/+YbIwnWabKSSWB iAbYCzzSRxnD5M3lhyjSW+DAWx1n+AbC2d9AgGtTg1zUKjxI+NHE9l+S3hWwXYzPg3ix lg4+19bkj3UxJO86cZQM6unSxZI9xbdKeQr190hE1a4ziSFJXYbWFGc6AHGq9LyeiGnz nQ03PrFOwcn9lqkWmBgSYOMrdhPjsLVJ6ucD3s3MhAbeH5nwspK3LXx1nMprW6eOWP/8 D0G9DeuoedkpR7cAkjUUI2SkVzK4Z3pc8MAkS6FhhILROZGELMY6eL+JogvtqmHjiKaK cZig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YOqVMx0C; 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=pass (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 187si11314559jaf.20.2021.09.24.10.19.51; Fri, 24 Sep 2021 10:20:16 -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=@linuxfoundation.org header.s=korg header.b=YOqVMx0C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345006AbhIXMx4 (ORCPT + 99 others); Fri, 24 Sep 2021 08:53:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:45754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344313AbhIXMwM (ORCPT ); Fri, 24 Sep 2021 08:52:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E11A161359; Fri, 24 Sep 2021 12:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632487765; bh=wuMnN238CAYwXN0qwKHd5Or0KpuSkE7Av/lZb/7bzdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOqVMx0CKhCpsktkULoIrzqOzoaqpzlnImFIAVnEoadl8ap4Vh3W7IOW2dBBPTI0y 7EkKtcDBx7F9dovGTvkuYuP95IOOvwh+ReZW4THjdi7nkR26/p09D4hgVxLsqKRMok LivNiZz5Xnbhthr46wO2Y4a3yu/sROWtP6Seefos= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nanyong Sun , Ryusuke Konishi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 28/34] nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group Date: Fri, 24 Sep 2021 14:44:22 +0200 Message-Id: <20210924124330.888108507@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124329.965218583@linuxfoundation.org> References: <20210924124329.965218583@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nanyong Sun [ Upstream commit b2fe39c248f3fa4bbb2a20759b4fdd83504190f7 ] 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. Link: https://lkml.kernel.org/r/20210629022556.3985106-6-sunnanyong@huawei.com Link: https://lkml.kernel.org/r/1625651306-10829-6-git-send-email-konishi.ryusuke@gmail.com Signed-off-by: Nanyong Sun Signed-off-by: Ryusuke Konishi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 195f42192a15..6c92ac314b06 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -208,9 +208,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.33.0