lkml.org 
[lkml]   [2020]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] qnx4: do not interpret -EIO as a correct address
Date
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@gmail.com>
> ---
> v2: also check other callers according to Anders Larsen's<al@alarsen.net> 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)

\
 
 \ /
  Last update: 2020-11-02 23:46    [W:0.076 / U:0.808 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site