diff mbox

pnfs/flexfiles: move kfree() after the deference

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

Commit Message

Dan Carpenter Feb. 11, 2015, 10:22 a.m. UTC
We dereference "err" in the the debug printk so we have to move the
kfree() down a couple lines.

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

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Trond Myklebust Feb. 11, 2015, 12:55 p.m. UTC | #1
Hi Dan,

On Wed, Feb 11, 2015 at 5:22 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We dereference "err" in the the debug printk so we have to move the
> kfree() down a couple lines.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> index 3bbb16b..e2c01f2 100644
> --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
> @@ -515,10 +515,10 @@ int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo,
>                 *p++ = cpu_to_be32(err->opnum);
>                 *count += 1;
>                 list_del(&err->list);
> -               kfree(err);
>                 dprintk("%s: offset %llu length %llu status %d op %d count %d\n",
>                         __func__, err->offset, err->length, err->status,
>                         err->opnum, *count);
> +               kfree(err);
>         }
>
>         return 0;

I believe this is a fix for the same bug that was reported by Julia
Lawall a couple of days ago. There should be a fix for this already at
http://git.linux-nfs.org/?p=trondmy/linux-nfs.git;a=commitdiff;h=480486b4733d5bc7d9fe765b34bc6c2b72d5c12e

Cheers
  Trond
diff mbox

Patch

diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index 3bbb16b..e2c01f2 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -515,10 +515,10 @@  int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo,
 		*p++ = cpu_to_be32(err->opnum);
 		*count += 1;
 		list_del(&err->list);
-		kfree(err);
 		dprintk("%s: offset %llu length %llu status %d op %d count %d\n",
 			__func__, err->offset, err->length, err->status,
 			err->opnum, *count);
+		kfree(err);
 	}
 
 	return 0;