Skip to contentSkip to conversation

ceph: quota: fix null pointer dereference in quota check

PATCH Applied Luis Henriques 2 participants 2 messages Nov 5, 2018 – Nov 6, 2018 1 message not in the archive Ceph client

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 ceph: quota: fix null pointer dereference in quota check

This patch fixes a possible null pointer dereference in check_quota_exceeded, detected by the static checker smatch, with the following warning:

fs/ceph/quota.c:240 check_quota_exceeded()
error: we previously assumed 'realm' could be null (see line 188)

Fixes b7a2921765cf ("ceph: quota: support for ceph.quota.max_files")
---
 fs/ceph/quota.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/quota.c +2 -1
index 32d4f13784ba..03f4d24db8fe 100644
@@ -237,7 +237,8 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
 		ceph_put_snap_realm(mdsc, realm);
 		realm = next;
 	}
-	ceph_put_snap_realm(mdsc, realm);
+	if (realm)
+		ceph_put_snap_realm(mdsc, realm);
 	up_read(&mdsc->snap_rwsem);
 
 	return exceeded;
Applied
#2 lore raw
Quoted 24 lines · Luis Henriques

This patch fixes a possible null pointer dereference in check_quota_exceeded, detected by the static checker smatch, with the following warning:

fs/ceph/quota.c:240 check_quota_exceeded()
error: we previously assumed 'realm' could be null (see line 188)

Fixes b7a2921765cf ("ceph: quota: support for ceph.quota.max_files")

---
fs/ceph/quota.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/quota.c +0 -0
index 32d4f13784ba..03f4d24db8fe 100644

fs/ceph/quota.c static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op, · line 244

Quoted 9 lines
fs/ceph/quota.c +2 -1
@@ -237,7 +237,8 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
 		ceph_put_snap_realm(mdsc, realm);
 		realm = next;
 	}
-	ceph_put_snap_realm(mdsc, realm);
+	if (realm)
+		ceph_put_snap_realm(mdsc, realm);
 	up_read(&mdsc->snap_rwsem);
 
 	return exceeded;

Applied, thanks.

Yan, Zheng