Re: [Kernel Bug] WARNING in vfat_rmdir

From: Matthew Wilcox
Date: Tue Dec 30 2025 - 01:45:24 EST


On Tue, Dec 30, 2025 at 02:18:17AM +0800, Zhiyu Zhang wrote:
> +++ b/fs/fat/dir.c
> @@ -92,8 +92,10 @@ static int fat__get_entry(struct inode *dir, loff_t *pos,
> *bh = NULL;
> iblock = *pos >> sb->s_blocksize_bits;
> err = fat_bmap(dir, iblock, &phys, &mapped_blocks, 0, false);
> - if (err || !phys)
> - return -1; /* beyond EOF or error */
> + if (err)
> + return err; /* real error (e.g., -EIO, -EUCLEAN) */
> + if (!phys)
> + return -1; /* beyond EOF */

Ooh, -1 is a real errno, so -1 or errno is a bad API. I'd suggest just
returning -ENOENT directly instead of translating it in the caller.