RE: [PATCH v2] qnx4: do not interpret -EIO as a correct address

From: David Laight
Date: Mon Nov 02 2020 - 17:45:05 EST


From: Tong Zhang
> Sent: 02 November 2020 20:16
>
> qnx4_block_map() may return -EIO on funny qnx4 fs image, in this case do
> not interpret -EIO as a correct address

'Block number' not 'address'.

> Signed-off-by: Tong Zhang <ztong0001@xxxxxxxxx>
> ---
> v2: also check other callers according to Anders Larsen's<al@xxxxxxxxxxx> comment
> fs/qnx4/dir.c | 2 ++
> fs/qnx4/inode.c | 2 ++
> fs/qnx4/namei.c | 3 +++
> 3 files changed, 7 insertions(+)
>
> diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
> index a6ee23aadd28..11aaf59f0411 100644
> --- a/fs/qnx4/dir.c
> +++ b/fs/qnx4/dir.c
> @@ -31,6 +31,8 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx)
>
> while (ctx->pos < inode->i_size) {
> blknum = qnx4_block_map(inode, ctx->pos >> QNX4_BLOCK_SIZE_BITS);
> + if (blknum == -EIO)
> + return -EIO;

Since 'blknum' is 'unsigned long' doesn't this generate a compiler
warning about the condition being always false?
(C requires the -EIO be converted to the equivalent unsigned
bit-pattern - but that doesn't stop the compiler deciding it is
dubious.)
If it doesn't this week, it might next week.

What about other error codes that might get returned.
Someone seeing that EIO is valid might decide an other
error can be returned.

You probably ought to allow for all errno values
or use ~0ull as an error value.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)