Skip to contentSkip to conversation

xfs_quota: Fix test for wrapped id from GETNEXTQUOTA

PATCH In review Eric Sandeen 3 participants 3 messages Dec 21, 2016 – Dec 22, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_quota: Fix test for wrapped id from GETNEXTQUOTA

dump_file and report_mount can be called with null *oid if we aren't asking for the GETNEXTQUOTA interface, so we should only test for the GETNEXTQUOTA wrap if *oid is non-null. Otherwise we'll deref a null pointer in the test.

This only happens for certain invocations of reporting, which apparently are not covered by any regression tests at this point, at least on new kernels which contain GETNEXTQUOTA.

Addresses-Coverity-ID: 1397415
Addresses-Coverity-ID: 1397416

---

quota/report.c +10 -10
index fc02302..3833dd6 100644
@@ -98,12 +98,12 @@ dump_file(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (*oid < id)
+			return 0;
+	}
 
 	if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
 	    !d.d_ino_softlimit && !d.d_ino_hardlimit &&
@@ -361,12 +361,12 @@ report_mount(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (* oid < id)
+			return 0;
+	}
 
 	if (flags & TERSE_FLAG) {
 		count = 0;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Eric Sandeen

dump_file and report_mount can be called with null *oid if we aren't asking for the GETNEXTQUOTA interface, so we should only test for the GETNEXTQUOTA wrap if *oid is non-null. Otherwise we'll deref a null pointer in the test.

This only happens for certain invocations of reporting, which apparently are not covered by any regression tests at this point, at least on new kernels which contain GETNEXTQUOTA.

Quoted 4 lines

Addresses-Coverity-ID: 1397415
Addresses-Coverity-ID: 1397416

Looks good.

Quoted 47 lines

---

quota/report.c +10 -11
index fc02302..3833dd6 100644
@@ -98,12 +98,12 @@ dump_file(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (*oid < id)
+			return 0;
+	}
 
 	if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
 	    !d.d_ino_softlimit && !d.d_ino_hardlimit &&
@@ -361,12 +361,12 @@ report_mount(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (* oid < id)
+			return 0;
+	}
 
 	if (flags & TERSE_FLAG) {
 		count = 0;
 
--

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

Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Sandeen
Quoted 10 lines · Eric Sandeen

dump_file and report_mount can be called with null *oid if we aren't asking for the GETNEXTQUOTA interface, so we should only test for the GETNEXTQUOTA wrap if *oid is non-null. Otherwise we'll deref a null pointer in the test.

This only happens for certain invocations of reporting, which apparently are not covered by any regression tests at this point, at least on new kernels which contain GETNEXTQUOTA.

Quoted 52 lines

Addresses-Coverity-ID: 1397415
Addresses-Coverity-ID: 1397416

---

quota/report.c +10 -11
index fc02302..3833dd6 100644
@@ -98,12 +98,12 @@ dump_file(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (*oid < id)
+			return 0;
+	}
 
 	if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
 	    !d.d_ino_softlimit && !d.d_ino_hardlimit &&
@@ -361,12 +361,12 @@ report_mount(
 		return 0;
 	}
 
-	if (oid)
+	if (oid) {
 		*oid = d.d_id;
-
-	/* Did kernelspace wrap? */
-	if (*oid < id)
-		return 0;
+		/* Did kernelspace wrap? */
+		if (* oid < id)
+			return 0;
+	}
 
 	if (flags & TERSE_FLAG) {
 		count = 0;
 
--

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

Signature · 1 line
Carlos