Skip to contentSkip to conversation

pnfs/flexfiles: move kfree() after the deference

PATCH In review Dan Carpenter 2 participants 2 messages Feb 11, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pnfs/flexfiles: move kfree() after the deference

We dereference "err" in the the debug printk so we have to move the kfree() down a couple lines.

fs/nfs/flexfilelayout/flexfilelayoutdev.c +1 -1
index 3bbb16b..e2c01f2 100644
@@ -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;
#1 lore raw

Hi Dan,

Quoted 11 lines · Dan Carpenter

We dereference "err" in the the debug printk so we have to move the kfree() down a couple lines.

fs/nfs/flexfilelayout/flexfilelayoutdev.c +0 -0
index 3bbb16b..e2c01f2 100644
@@ -515,10 +515,10 @@ int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo,
                *p++ = cpu_to_be32(err->opnum);

fs/nfs/flexfilelayout/flexfilelayoutdev.c int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo, · line 524

Quoted 10 lines
fs/nfs/flexfilelayout/flexfilelayoutdev.c +1 -1
                *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;hH0486b4733d5bc7d9fe765b34bc6c2b72d5c12e

Cheers
Trond

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]