Skip to contentSkip to conversation

nfs: fix NULL pointer dereference in nfs4_fl_prepare_ds

PATCH In review Jeff Layton 1 participant 2 messages Sep 25, 2013 – Sep 26, 2013

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

PATCH 1/1 nfs: fix NULL pointer dereference in nfs4_fl_prepare_ds

In the event that there is an error connecting to a DS, we currently zero out the ds pointer and then try to dereference it to clear the NFS4DS_CONNECTING bit.

Fix this by clearing the bit unconditionally before zeroing out the pointer.

Cc Andy Adamson <[email protected]>
Cc <[email protected]> # v3.10+
---
 fs/nfs/nfs4filelayoutdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/nfs4filelayoutdev.c +1 -1
index 95604f6..816cda8 100644
@@ -819,11 +819,11 @@ nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
 		int err;
 
 		err = nfs4_ds_connect(s, ds);
+		nfs4_clear_ds_conn_bit(ds);
 		if (err) {
 			nfs4_mark_deviceid_unavailable(devid);
 			ds = NULL;
 		}
-		nfs4_clear_ds_conn_bit(ds);
 	} else {
 		/* Either ds is connected, or ds is NULL */
 		nfs4_wait_ds_connect(ds);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 21 lines · On Wed, 25 Sep 2013 16:20:57 -0400 Jeff Layton <[email protected]> wrote:

In the event that there is an error connecting to a DS, we currently zero out the ds pointer and then try to dereference it to clear the NFS4DS_CONNECTING bit.

Fix this by clearing the bit unconditionally before zeroing out the pointer.

Cc Andy Adamson <[email protected]>
Cc <[email protected]> # v3.10+
---
 fs/nfs/nfs4filelayoutdev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/nfs4filelayoutdev.c +0 -0
index 95604f6..816cda8 100644
@@ -819,11 +819,11 @@ nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx)
 		int err;
 

fs/nfs/nfs4filelayoutdev.c nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx) · line 829

Quoted 10 lines
fs/nfs/nfs4filelayoutdev.c +1 -1
 		err = nfs4_ds_connect(s, ds);
+		nfs4_clear_ds_conn_bit(ds);
 		if (err) {
 			nfs4_mark_deviceid_unavailable(devid);
 			ds = NULL;
 		}
-		nfs4_clear_ds_conn_bit(ds);
 	} else {
 		/* Either ds is connected, or ds is NULL */
 		nfs4_wait_ds_connect(ds);

Trond,

Please disregard this patch. There's another problem in here that we'll need to fix too. Andy will be sending along a replacement patch later that should fix this bug and the other problems too.

Signature · 1 line
Jeff Layton <[email protected]>