Skip to contentSkip to conversation

xfs: check for null dquot in xfs_quota_calc_throttle()

PATCH In review Eric Sandeen 2 participants 2 messages Oct 1, 2014 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: check for null dquot in xfs_quota_calc_throttle()

Coverity spotted this.

Granted, we *just* checked xfs_inod_dquot() in the caller (by calling xfs_quota_need_throttle), but to be honest I don't know if this can race, and this is the only place we don't check the return value - and the check seems cheap and future-proof.

---

Sorry for the handwavy commit log, if it's obvious that it can race, feel free to fix the description. ;)

fs/xfs/xfs_iomap.c +2 -2
index e9c47b6..afcf3c9 100644
@@ -404,8 +404,8 @@ xfs_quota_calc_throttle(
 	int shift = 0;
 	struct xfs_dquot *dq = xfs_inode_dquot(ip, type);
 
-	/* over hi wmark, squash the prealloc completely */
-	if (dq->q_res_bcount >= dq->q_prealloc_hi_wmark) {
+	/* no dq, or over hi wmark, squash the prealloc completely */
+	if (!dq || dq->q_res_bcount >= dq->q_prealloc_hi_wmark) {
 		*qblocks = 0;
 		*qfreesp = 0;
 		return;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Eric Sandeen

Coverity spotted this.

Granted, we *just* checked xfs_inod_dquot() in the caller (by calling xfs_quota_need_throttle), but to be honest I don't know if this can race, and this is the only place we don't check the return value - and the check seems cheap and future-proof.

Quoted 5 lines

---

Sorry for the handwavy commit log, if it's obvious that it can race, feel free to fix the description. ;)

Description changed simply to say:

... this is the only place we don't check the return value, but the check is cheap and future-proof, so add it.

And so:

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs