diff mbox

fs/affs: fix an error code in affs_write_end_ofs()

Message ID 20170520094946.o6l7rmizlvwq7mjg@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter May 20, 2017, 9:49 a.m. UTC
"prev_bh" is a valid pointer.  "bh" is an error pointer.  "written" is
either an error pointer, or a the number of bytes we have written.  If
we haven't written any bytes then we want to return the error code
stored in "bh".  So we need to that before resetting "bh" to a valid
pointer.

This bug is older than git.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Fabian Frederick May 28, 2017, 12:03 p.m. UTC | #1
Hi Dan,

> On 20 May 2017 at 11:49 Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
>
> "prev_bh" is a valid pointer.  "bh" is an error pointer.  "written" is
> either an error pointer, or a the number of bytes we have written.  If
> we haven't written any bytes then we want to return the error code
> stored in "bh".  So we need to that before resetting "bh" to a valid
> pointer.
>
> This bug is older than git.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Fabian Frederick <fabf@skynet.be>

>
> diff --git a/fs/affs/file.c b/fs/affs/file.c
> index 196ee7f6fdc4..99610050199c 100644
> --- a/fs/affs/file.c
> +++ b/fs/affs/file.c
> @@ -800,9 +800,9 @@ static int affs_write_end_ofs(struct file *file, struct
> address_space *mapping,
>       return written;

>  err_bh:
> -     bh = prev_bh;
>       if (!written)
>               written = PTR_ERR(bh);
> +     bh = prev_bh;
>       goto done;
>  }
>
diff mbox

Patch

diff --git a/fs/affs/file.c b/fs/affs/file.c
index 196ee7f6fdc4..99610050199c 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -800,9 +800,9 @@  static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
 	return written;
 
 err_bh:
-	bh = prev_bh;
 	if (!written)
 		written = PTR_ERR(bh);
+	bh = prev_bh;
 	goto done;
 }