aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ceph
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-01-09 16:34:32 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-09 16:36:12 -0500
commit3c5184ef1216dd476c9c67f22a199d90ac4d5892 (patch)
treef6bd6d77ee9d1260892c8e8589497eaa2f5efbab /fs/ceph
parent94bf608a18fa4421315275a81c5489734599297a (diff)
ceph: d_alloc_root() may fail
... and ceph_init_dentry(NULL) will oops Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ceph')
-rw-r--r--fs/ceph/super.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 11bd0fc4853f..48f61a12af66 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -636,19 +636,26 @@ static struct dentry *open_root_dentry(struct ceph_fs_client *fsc,
636 req->r_num_caps = 2; 636 req->r_num_caps = 2;
637 err = ceph_mdsc_do_request(mdsc, NULL, req); 637 err = ceph_mdsc_do_request(mdsc, NULL, req);
638 if (err == 0) { 638 if (err == 0) {
639 struct inode *inode = req->r_target_inode;
640 req->r_target_inode = NULL;
639 dout("open_root_inode success\n"); 641 dout("open_root_inode success\n");
640 if (ceph_ino(req->r_target_inode) == CEPH_INO_ROOT && 642 if (ceph_ino(inode) == CEPH_INO_ROOT &&
641 fsc->sb->s_root == NULL) { 643 fsc->sb->s_root == NULL) {
642 root = d_alloc_root(req->r_target_inode); 644 root = d_alloc_root(inode);
645 if (!root) {
646 iput(inode);
647 root = ERR_PTR(-ENOMEM);
648 goto out;
649 }
643 ceph_init_dentry(root); 650 ceph_init_dentry(root);
644 } else { 651 } else {
645 root = d_obtain_alias(req->r_target_inode); 652 root = d_obtain_alias(inode);
646 } 653 }
647 req->r_target_inode = NULL;
648 dout("open_root_inode success, root dentry is %p\n", root); 654 dout("open_root_inode success, root dentry is %p\n", root);
649 } else { 655 } else {
650 root = ERR_PTR(err); 656 root = ERR_PTR(err);
651 } 657 }
658out:
652 ceph_mdsc_put_request(req); 659 ceph_mdsc_put_request(req);
653 return root; 660 return root;
654} 661}