Whamcloud - gitweb
LU-3283 llite: check ll_prep_md_op_data() using IS_ERR()
authorJohn L. Hammond <john.hammond@intel.com>
Mon, 6 May 2013 21:53:38 +0000 (16:53 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 3 Jun 2013 19:56:22 +0000 (15:56 -0400)
In ll_file_ioctl() and ll_swap_layouts() check the result of
ll_prep_md_op_data() using IS_ERR().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ib916635559863cd7a8aee3c88bb1d2bb2e7921b8
Reviewed-on: http://review.whamcloud.com/6275
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/file.c

index 85c3944..270029e 100644 (file)
@@ -1967,12 +1967,12 @@ static int ll_swap_layouts(struct file *file1, struct file *file2,
        rc = -ENOMEM;
        op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0,
                                     0, LUSTRE_OPC_ANY, &msl);
-       if (op_data != NULL) {
-               rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS,
-                                  ll_i2mdexp(llss->inode1),
-                                  sizeof(*op_data), op_data, NULL);
-               ll_finish_md_op_data(op_data);
-       }
+       if (IS_ERR(op_data))
+               GOTO(free, rc = PTR_ERR(op_data));
+
+       rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, ll_i2mdexp(llss->inode1),
+                          sizeof(*op_data), op_data, NULL);
+       ll_finish_md_op_data(op_data);
 
 putgl:
        if (gid != 0) {
@@ -2166,9 +2166,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
                op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
                                             LUSTRE_OPC_ANY, hus);
-               if (op_data == NULL) {
+               if (IS_ERR(op_data)) {
                        OBD_FREE_PTR(hus);
-                       RETURN(-ENOMEM);
+                       RETURN(PTR_ERR(op_data));
                }
 
                rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
@@ -2204,9 +2204,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
                op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
                                             LUSTRE_OPC_ANY, hss);
-               if (op_data == NULL) {
+               if (IS_ERR(op_data)) {
                        OBD_FREE_PTR(hss);
-                       RETURN(-ENOMEM);
+                       RETURN(PTR_ERR(op_data));
                }
 
                rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),
@@ -2228,9 +2228,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
                op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
                                             LUSTRE_OPC_ANY, hca);
-               if (op_data == NULL) {
+               if (IS_ERR(op_data)) {
                        OBD_FREE_PTR(hca);
-                       RETURN(-ENOMEM);
+                       RETURN(PTR_ERR(op_data));
                }
 
                rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data),