From: Yuezhang Mo Date: Mon, 2 Dec 2024 01:53:17 +0000 (+0800) Subject: exfat: fix exfat_find_empty_entry() not returning error on failure X-Git-Tag: v6.13-rc7~36^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=70465acbb0ce1bb69447acf32f136c8153cda0de;p=thirdparty%2Fkernel%2Flinux.git exfat: fix exfat_find_empty_entry() not returning error on failure On failure, "dentry" is the error code. If the error code indicates that there is no space, a new cluster may need to be allocated; for other errors, it should be returned directly. Only on success, "dentry" is the index of the directory entry, and it needs to be converted into the directory entry index within the cluster where it is located. Fixes: 8a3f5711ad74 ("exfat: reduce FAT chain traversal") Reported-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Tested-by: syzbot+6f6c9397e0078ef60bce@syzkaller.appspotmail.com Signed-off-by: Yuezhang Mo Reviewed-by: Sungjong Seo Signed-off-by: Namjae Jeon --- diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index 97d2774760fe3..099f806450721 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -330,8 +330,8 @@ static int exfat_find_empty_entry(struct inode *inode, while ((dentry = exfat_search_empty_slot(sb, &hint_femp, p_dir, num_entries, es)) < 0) { - if (dentry == -EIO) - break; + if (dentry != -ENOSPC) + return dentry; if (exfat_check_max_dentries(inode)) return -ENOSPC;