]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: ensure we have a new cap before continuing in fill_inode
authorJeff Layton <jlayton@kernel.org>
Thu, 5 Dec 2019 13:41:25 +0000 (08:41 -0500)
committerJeff Layton <jlayton@kernel.org>
Fri, 10 Jan 2020 16:51:04 +0000 (11:51 -0500)
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>
fs/ceph/inode.c

index ffef475af72b868f3c5333caa96c561a1a519e2b..aee7a24bf1bc8c0ee0398351bc61458dd24b52a6 100644 (file)
@@ -756,8 +756,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