Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1856134pxb; Fri, 24 Sep 2021 13:38:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8GpiCVDJzS8mSB4wnjZQJjXNzhL3l7SAXOmFH+9RQ+Ikkz1m9zQup4Yu+W068QSws3c9/ X-Received: by 2002:a17:906:f6d3:: with SMTP id jo19mr3056276ejb.99.1632515908544; Fri, 24 Sep 2021 13:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632515908; cv=none; d=google.com; s=arc-20160816; b=vINiNY/TLHeiQR1g2lyPGVQ0qfsw/8wCxEV+OSPT0WPiBiNQUG04XL+oEH4T8f65ZO 90es5fQvZjzu7dLJGal82cNFURppK1Ho3cg6N7WVYdRLv3DLZcERiiUh/c5DMMp1YsOs hR/hM8mDTzu3fbAhW1MwCDYc4yJNxByONLv4zwYS0WokUFdKD/2dsHqMI5jEVTsYZwBc simL7ERXp3+EEMQDyld2bW5ABmtGyW21t0yaiEcx1+UiiJe/u7zn/iHH2xaWFYBBt4RK qszMx6T3SmVQjq67liDIvkc/KJ4Z9LhDpl4MuHkRQsCOh5gB+zmsX1zfgfOezb6EauAe eDYg== 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=MI+H1xU5qIO+0Xy7XS4VGjeaLuNU97SJrMmCUBdbg+o=; b=MW+0jaTU00WVeWK4dnK6N/v6tyOQRwRvTQlbonM8h5aHEQXa6nj3soFuc19SfZO+IK 3A7CAmANwi3bcGjNyKGt5XIYYRb8vN8SszTI8e1jRHPWDu+HY3A0lUEfvhM+q3FSGfuf EOswnSIx9LEd9hkaYXoThYWywFi1uf3+WvrZQ2jjgIHJbRs/yeYPgu4cBCJ45AgYgLT2 qLUkqh0pzf5BTIKaqBq398A7a9M/QQPxliU/xSsrd+0vbJgGfRzH4Q07ARhWw+dXonjY DQJFXYbIB0me0j7Hf73eELmE+o1j12cGMYRPT2eufdSxxi/daSSr/EAChcDtsfPMEPtS 9pdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nv7c1wVb; 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 c7si10446446edk.101.2021.09.24.13.38.05; Fri, 24 Sep 2021 13:38:28 -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=nv7c1wVb; 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 S1346535AbhIXNPu (ORCPT + 99 others); Fri, 24 Sep 2021 09:15:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:38844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346632AbhIXNKO (ORCPT ); Fri, 24 Sep 2021 09:10:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3D3E461555; Fri, 24 Sep 2021 12:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632488282; bh=UeBROoZE8I14fO4wH1+GgC1sxKy7eBLxxiwXXDRBVzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nv7c1wVbDT2rb+jNXJlM0fJgdMT68LEriyAyebg4Oki37FyFfLqXGfAYRgnk1ViWg gszc8r8zIY8oqWf359mB+n/DseQXIkh4awCw5QADmgak3fFwo7u3i2Pcz1c9SHYxU7 txdmskaMgYb9HR9cT7eVbn0cnN71kyypylkCRags= 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 5.10 53/63] nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group Date: Fri, 24 Sep 2021 14:44:53 +0200 Message-Id: <20210924124336.095937907@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124334.228235870@linuxfoundation.org> References: <20210924124334.228235870@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 34893a57a7b9..44b9ad70a564 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