From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AFD03EDE51; Tue, 12 May 2026 18:14:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778609641; cv=none; b=Vs1X1WuhLoeFt3nAKCW8ZOMmJVg1PbdFR3RyXldz397WRol5pNpfeE/LUoV8M/tWMitHYmj831uJRUjHbI1WIVzaMtI9JgAtEPiFhyglbITATLBVfjsKheuX/zYhlhQcC6NhLlXC36Cvc7sELnkjh44slRpCTLHRqfKL6oS3/J4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778609641; c=relaxed/simple; bh=x9FyGUwNpDgf5nuZ0LuJG7V32GPoqJUUAKXqLMCcnCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n0zHlvefVLnX4Uh24kq95nsyJrVc2DM+uoj6diV+lotBIqeiPaF0I4pMxvh99EPmvXafq60hOZ9zOdUfMa58KJW2r9ccTZWj0Rbrt2sF5KRZ1dVnyWPvEx9YuMGSZx8s1XCdO0+4lLH33PuPiu1wO4jPmJSwodULc6Bg8MqhH70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BXP+z1FW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BXP+z1FW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A585BC2BCFB; Tue, 12 May 2026 18:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778609641; bh=x9FyGUwNpDgf5nuZ0LuJG7V32GPoqJUUAKXqLMCcnCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BXP+z1FWxzXE9omMdkvMnS9Czd33sMKcH2Ci7FBLsuJB7Cn7I35REM1+wehCsLa2O T907FNFu376elTAQDzctG2OYhFPEMaFA8EW0sT+7PrCRNhVJklyMnGA2yWZmgnCeSm O95qcwiDYaliMypaf+0SsjIy+ohP/i0cTX9oYQ3c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Chao Yu , Jaegeuk Kim Subject: [PATCH 7.0 274/307] f2fs: fix uninitialized kobject put in f2fs_init_sysfs() Date: Tue, 12 May 2026 19:41:09 +0200 Message-ID: <20260512173945.908103813@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173940.117428952@linuxfoundation.org> References: <20260512173940.117428952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li commit b635f2ecdb5ad34f9c967cabb704d6bed9382fd0 upstream. In f2fs_init_sysfs(), all failure paths after kset_register() jump to put_kobject, which unconditionally releases both f2fs_tune and f2fs_feat. If kobject_init_and_add(&f2fs_feat, ...) fails, f2fs_tune has not been initialized yet, so calling kobject_put(&f2fs_tune) is invalid. Fix this by splitting the unwind path so each error path only releases objects that were successfully initialized. Fixes: a907f3a68ee26ba4 ("f2fs: add a sysfs entry to reclaim POSIX_FADV_NOREUSE pages") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Greg Kroah-Hartman --- fs/f2fs/sysfs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1984,24 +1984,26 @@ int __init f2fs_init_sysfs(void) ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype, NULL, "features"); if (ret) - goto put_kobject; + goto unregister_kset; ret = kobject_init_and_add(&f2fs_tune, &f2fs_tune_ktype, NULL, "tuning"); if (ret) - goto put_kobject; + goto put_feat; f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); if (!f2fs_proc_root) { ret = -ENOMEM; - goto put_kobject; + goto put_tune; } return 0; -put_kobject: +put_tune: kobject_put(&f2fs_tune); +put_feat: kobject_put(&f2fs_feat); +unregister_kset: kset_unregister(&f2fs_kset); return ret; }