qnx4: do not interpret -EIO as a correct address
diff mbox series

Message ID 20201023211604.159074-1-ztong0001@gmail.com
State New, archived
Headers show
Series
  • qnx4: do not interpret -EIO as a correct address
Related show

Commit Message

Tong Zhang Oct. 23, 2020, 9:16 p.m. UTC
qnx4_block_map() may return -EIO on funny qnx4 fs image, in this case do
not interpret -EIO as a correct address

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
 fs/qnx4/inode.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Anders Larsen Nov. 2, 2020, 9:12 a.m. UTC | #1
On Friday, 2020-10-23 23:16 Tong Zhang wrote:
> qnx4_block_map() may return -EIO on funny qnx4 fs image, in this case do
> not interpret -EIO as a correct address
> 
> Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> ---
>  fs/qnx4/inode.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
> index e8da1cde87b9..d3a40c5b1a9a 100644
> --- a/fs/qnx4/inode.c
> +++ b/fs/qnx4/inode.c
> @@ -59,6 +59,8 @@ static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h
>  	QNX4DEBUG((KERN_INFO "qnx4: qnx4_get_block inode=[%ld] iblock=[%ld]\n",inode->i_ino,iblock));
>  
>  	phys = qnx4_block_map( inode, iblock );
> +	if (phys == -EIO)
> +		return -EIO;
>  	if ( phys ) {
>  		// logical block is before EOF
>  		map_bh(bh, inode->i_sb, phys);

The fix looks sane to me, but how about the two other callers of
qnx4_block_map(), are they not affected as well?

Cheers
Anders
Tong Zhang Nov. 2, 2020, 8:17 p.m. UTC | #2
Thanks Anders!
I'm sending out another patch fixing other callers as suggested.
- Tong

On Mon, Nov 2, 2020 at 4:12 AM Anders Larsen <al@alarsen.net> wrote:
>
> On Friday, 2020-10-23 23:16 Tong Zhang wrote:
> > qnx4_block_map() may return -EIO on funny qnx4 fs image, in this case do
> > not interpret -EIO as a correct address
> >
> > Signed-off-by: Tong Zhang <ztong0001@gmail.com>
> > ---
> >  fs/qnx4/inode.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
> > index e8da1cde87b9..d3a40c5b1a9a 100644
> > --- a/fs/qnx4/inode.c
> > +++ b/fs/qnx4/inode.c
> > @@ -59,6 +59,8 @@ static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h
> >       QNX4DEBUG((KERN_INFO "qnx4: qnx4_get_block inode=[%ld] iblock=[%ld]\n",inode->i_ino,iblock));
> >
> >       phys = qnx4_block_map( inode, iblock );
> > +     if (phys == -EIO)
> > +             return -EIO;
> >       if ( phys ) {
> >               // logical block is before EOF
> >               map_bh(bh, inode->i_sb, phys);
>
> The fix looks sane to me, but how about the two other callers of
> qnx4_block_map(), are they not affected as well?
>
> Cheers
> Anders
>
>

Patch
diff mbox series

diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index e8da1cde87b9..d3a40c5b1a9a 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -59,6 +59,8 @@  static int qnx4_get_block( struct inode *inode, sector_t iblock, struct buffer_h
 	QNX4DEBUG((KERN_INFO "qnx4: qnx4_get_block inode=[%ld] iblock=[%ld]\n",inode->i_ino,iblock));
 
 	phys = qnx4_block_map( inode, iblock );
+	if (phys == -EIO)
+		return -EIO;
 	if ( phys ) {
 		// logical block is before EOF
 		map_bh(bh, inode->i_sb, phys);