ceph: Add check returned value on func ceph_calc_ceph_pg.
authormajianpeng <majianpeng@gmail.com>
Fri, 2 Aug 2013 10:14:48 +0000 (18:14 +0800)
committerSage Weil <sage@inktank.com>
Sat, 10 Aug 2013 00:55:21 +0000 (17:55 -0700)
Func ceph_calc_ceph_pg maybe failed.So add check for returned value.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
Reviewed-by: Sage Weil <sage@inktank.com>
Signed-off-by: Sage Weil <sage@inktank.com>
fs/ceph/ioctl.c

index a5ce62eb7806daf0722d1950f26015a11e67275c..669622fd1ae3d52af418cc4c283a5f22513bca73 100644 (file)
@@ -211,8 +211,12 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)
        snprintf(dl.object_name, sizeof(dl.object_name), "%llx.%08llx",
                 ceph_ino(inode), dl.object_no);
 
-       ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap,
-               ceph_file_layout_pg_pool(ci->i_layout));
+       r = ceph_calc_ceph_pg(&pgid, dl.object_name, osdc->osdmap,
+                               ceph_file_layout_pg_pool(ci->i_layout));
+       if (r < 0) {
+               up_read(&osdc->map_sem);
+               return r;
+       }
 
        dl.osd = ceph_calc_pg_primary(osdc->osdmap, pgid);
        if (dl.osd >= 0) {