From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A7AEB42A144; Sat, 12 Sep 2026 17:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789232764; cv=none; b=rDNy01U6ruJIz/RPme1AQGGhsKn07NWk0Znc73nlrxKinzQeY+/rpBhDfyipY2JN/9VRn4HK3/u6aI+wiKO6KHgQxCmJzdwfOvmg6zWBJ/WEdpiWBF+z5Tdv2qkS+RSY0sAPeDKFIy6vtFAULb7h2/jcnLS9DEk3XxK+W8kbpyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789232764; c=relaxed/simple; bh=n1/ABdHgoY8Wep9/sDQgFyund4Ud+pT0QS8vFwccVZE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DBHgbjOHZ/p0hYhcel7Oe8SM8+4oMNp5RhHYZFCt8dgQ1Hca6KI83ENId1FWKm66vVrujk+x8+3vY5n8Be3Zqt8goNRhwhrFn1YNZ6ylUYVt24+TPM9v7b6NVGdDsNYgVC0nm7UGUDkXjXbdCwMaqBF4n/geAZH5aCauqSRQmlM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hMbG5nwv; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hMbG5nwv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C32721F000FF; Sat, 12 Sep 2026 17:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789232761; bh=7w36qN/70AzTJDidAPjdKSCDlLRYkCjna2PBWNoK/J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hMbG5nwvpf/ieI59Rze2u4r1pubFE6CU5vHtxKXd0Gr/62RsXQJR3nhk7VL/K9h4U 6YiwJHgbHJ8iZSx4U5AjbCF31E8AAd/AdSJLbSTurxUzNbL61oC6ajoFD9hoJYzBCI 8AGS+O3pHy/jhH2TBqXD25oIQDHWAXey0f3qw12w= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yemu Lu , Ren Wei , Yuan Tan , Yifan Wu , Juefei Pu , Xin Liu , OGAWA Hirofumi , Christian Brauner , Andrew Morton Subject: [PATCH 5.15 074/935] fat: restore original value when fat_ent_write failed Date: Sat, 12 Sep 2026 08:51:44 +0200 Message-ID: <20260912065528.530267088@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yemu Lu commit 64d9183203eebe33de6188b70a8c1e91f52885db upstream. fat_ent_write() may have committed the new link to the primary FAT but then failed on the mirror copy, leaving the chain pointing to new_dclus even though the caller will free it. Restore the original value to keep the chain consistent. Link: https://lore.kernel.org/20260525085649.781643-1-n05ec@lzu.edu.cn Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Yemu Lu Signed-off-by: Ren Wei Reported-by: Yuan Tan Reported-by: Yifan Wu Reported-by: Juefei Pu Reported-by: Xin Liu Acked-by: OGAWA Hirofumi Cc: Christian Brauner Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/fat/misc.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/fat/misc.c +++ b/fs/fat/misc.c @@ -127,7 +127,11 @@ int fat_chain_add(struct inode *inode, i ret = fat_ent_read(inode, &fatent, last); if (ret >= 0) { int wait = inode_needs_sync(inode); + int old = ret; + ret = fat_ent_write(inode, &fatent, new_dclus, wait); + if (ret < 0) + fat_ent_write(inode, &fatent, old, wait); fatent_brelse(&fatent); } if (ret < 0)