Re: [PATCH 1/3] Corrected errno in minix_new_inode
From: Jan Kara
Date: Mon Nov 24 2025 - 12:31:09 EST
On Mon 17-11-25 23:05:20, Jori Koolstra wrote:
> The cases (!j || j > sbi->s_ninodes) can never occur unless the
> filesystem is broken, so this should not return ENOSPC, but
> EFSCORRUPTED.
I agree with this.
> I also removed a redundant assignment: sbi->s_imap_blocks can never be
> 0, so j is always immediately overwritten.
OK, but this will make the compiler likely unhappy (because it doesn't know
s_imap_blocks cannot be 0) and generally the code will be less
self-containted. So in the spirit of defensive programming I'd leave the
assignment there.
Honza
>
> Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
> ---
> fs/minix/bitmap.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
> index 7da66ca184f4..9d9c2819b22b 100644
> --- a/fs/minix/bitmap.c
> +++ b/fs/minix/bitmap.c
> @@ -222,7 +222,6 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode)
>
> if (!inode)
> return ERR_PTR(-ENOMEM);
> - j = bits_per_zone;
> bh = NULL;
> spin_lock(&bitmap_lock);
> for (i = 0; i < sbi->s_imap_blocks; i++) {
> @@ -247,7 +246,7 @@ struct inode *minix_new_inode(const struct inode *dir, umode_t mode)
> j += i * bits_per_zone;
> if (!j || j > sbi->s_ninodes) {
> iput(inode);
> - return ERR_PTR(-ENOSPC);
> + return ERR_PTR(-EFSCORRUPTED);
> }
> inode_init_owner(&nop_mnt_idmap, inode, dir, mode);
> inode->i_ino = j;
>
> base-commit: 0d534518ce87317e884dbd1485111b0f1606a194
> --
> 2.51.2
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR