summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@kernel.org>2019-12-05 08:41:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-10-01 13:17:29 +0200
commit379deeac55dafdc9e43c5f9c95e8c04f6ce0a168 (patch)
tree991220044cf94a21caade2bdce3421a87aa6e8fa /fs
parent5a5fa887629173bf884cfde5c5b9b60ca1bf8674 (diff)
ceph: ensure we have a new cap before continuing in fill_inode
[ Upstream commit 9a6bed4fe0c8bf57785cbc4db9f86086cb9b193d ] If the caller passes in a NULL cap_reservation, and we can't allocate one then ensure that we fail gracefully. Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ceph/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index c07407586ce8..660a878e20ef 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -754,8 +754,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
info_caps = le32_to_cpu(info->cap.caps);
/* prealloc new cap struct */
- if (info_caps && ceph_snap(inode) == CEPH_NOSNAP)
+ if (info_caps && ceph_snap(inode) == CEPH_NOSNAP) {
new_cap = ceph_get_cap(mdsc, caps_reservation);
+ if (!new_cap)
+ return -ENOMEM;
+ }
/*
* prealloc xattr data, if it looks like we'll need it. only