Commit eed2903a authored by dongliang.cui's avatar dongliang.cui Committed by Treehugger Robot
Browse files

UPSTREAM: exfat: fix appending discontinuous clusters to empty file



Eric Hong found that when using ftruncate to expand an empty file,
exfat_ent_set() will fail if discontinuous clusters are allocated.
The reason is that the empty file does not have a cluster chain,
but exfat_ent_set() attempts to append the newly allocated cluster
to the cluster chain. In addition, exfat_find_last_cluster() only
supports finding the last cluster in a non-empty file.

So this commit adds a check whether the file is empty. If the file
is empty, exfat_find_last_cluster() and exfat_ent_set() are no longer
called as they do not need to be called.

Fixes: f55c096f ("exfat: do not zero the extended part")
Reported-by: default avatarEric Hong <erichong@qnap.com>
Signed-off-by: default avatarYuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
(cherry picked from commit 3a784504)

Bug: 362138008

Change-Id: Id3af6cb1442f77e016b18188b4488789c739f01f
Signed-off-by: default avatardongliang.cui <dongliang.cui@unisoc.com>
parent 0bcb2463
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment