Skip to content

Commit 71f2cc6

Browse files
Luis Henriquesidryomov
authored andcommitted
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: b7a2921 ("ceph: quota: support for ceph.quota.max_files") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Luis Henriques <lhenriques@suse.com> Reviewed-by: "Yan, Zheng" <zyan@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent c2c6d3c commit 71f2cc6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ceph/quota.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op,
237237
ceph_put_snap_realm(mdsc, realm);
238238
realm = next;
239239
}
240-
ceph_put_snap_realm(mdsc, realm);
240+
if (realm)
241+
ceph_put_snap_realm(mdsc, realm);
241242
up_read(&mdsc->snap_rwsem);
242243

243244
return exceeded;

0 commit comments

Comments
 (0)