summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorLuis Henriques <lhenriques@suse.com>2018-11-05 22:00:52 +0300
committerIlya Dryomov <idryomov@gmail.com>2018-11-08 19:51:11 +0300
commit71f2cc64d027d712f29bf8d09d3e123302d5f245 (patch)
tree1544bc4e5ac8b4588f015352e83f5595e70755b7 /fs
parentc2c6d3ce0d9a1fae4472fc10755372d022a487a4 (diff)
downloadlinux-71f2cc64d027d712f29bf8d09d3e123302d5f245.tar.xz
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") 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>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/quota.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c
index 32d4f13784ba..03f4d24db8fe 100644
--- a/fs/ceph/quota.c
+++ b/fs/ceph/quota.c
@@ -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;