Whamcloud - gitweb
LU-3576 mdc: prevent fall through in mdc_iocontrol() 76/7276/3
authorJohn L. Hammond <john.hammond@intel.com>
Fri, 12 Jul 2013 15:21:48 +0000 (10:21 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 10 Aug 2013 00:07:45 +0000 (00:07 +0000)
In mdc_iocontrol() add a goto to the end of the LL_IOC_HSM_STATE_SET
case, preventing fall through into the next case. In the same
function, replace the return statement in OBD_IOC_QUOTACTL with a
goto, so that a reference to the module is not leaked.

Lustre-commit: 0d166ef1fd80b0056497969b956d04e32e86aa85
Lustre-change: http://review.whamcloud.com/6962

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Change-Id: I762de2aaf794f1691cb243feed5b65289f91e1dd
Reviewed-on: http://review.whamcloud.com/7276
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Aurelien Degremont <aurelien.degremont@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdc/mdc_request.c

index 393a5f1..2f373ec 100644 (file)
@@ -1837,6 +1837,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                GOTO(out, rc);
        case LL_IOC_HSM_STATE_SET:
                rc = mdc_ioc_hsm_state_set(exp, karg);
+               GOTO(out, rc);
        case LL_IOC_HSM_ACTION:
                rc = mdc_ioc_hsm_current_action(exp, karg);
                GOTO(out, rc);
@@ -1905,44 +1906,42 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
                 GOTO(out, rc = 0);
         }
-        case OBD_IOC_QUOTACTL: {
-                struct if_quotactl *qctl = karg;
-                struct obd_quotactl *oqctl;
+       case OBD_IOC_QUOTACTL: {
+               struct if_quotactl *qctl = karg;
+               struct obd_quotactl *oqctl;
 
-                OBD_ALLOC_PTR(oqctl);
-                if (!oqctl)
-                        RETURN(-ENOMEM);
+               OBD_ALLOC_PTR(oqctl);
+               if (oqctl == NULL)
+                       GOTO(out, rc = -ENOMEM);
 
-                QCTL_COPY(oqctl, qctl);
-                rc = obd_quotactl(exp, oqctl);
-                if (rc == 0) {
-                        QCTL_COPY(qctl, oqctl);
-                        qctl->qc_valid = QC_MDTIDX;
-                        qctl->obd_uuid = obd->u.cli.cl_target_uuid;
-                }
-                OBD_FREE_PTR(oqctl);
-                break;
-        }
-       case LL_IOC_GET_CONNECT_FLAGS: {
-               if (cfs_copy_to_user(uarg,
-                                    exp_connect_flags_ptr(exp),
-                                    sizeof(__u64)))
-                       GOTO(out, rc = -EFAULT);
-               else
-                       GOTO(out, rc = 0);
+               QCTL_COPY(oqctl, qctl);
+               rc = obd_quotactl(exp, oqctl);
+               if (rc == 0) {
+                       QCTL_COPY(qctl, oqctl);
+                       qctl->qc_valid = QC_MDTIDX;
+                       qctl->obd_uuid = obd->u.cli.cl_target_uuid;
+               }
+
+               OBD_FREE_PTR(oqctl);
+               GOTO(out, rc);
        }
-       case LL_IOC_LOV_SWAP_LAYOUTS: {
+       case LL_IOC_GET_CONNECT_FLAGS:
+               if (cfs_copy_to_user(uarg, exp_connect_flags_ptr(exp),
+                                sizeof(*exp_connect_flags_ptr(exp))))
+                       GOTO(out, rc = -EFAULT);
+
+               GOTO(out, rc = 0);
+       case LL_IOC_LOV_SWAP_LAYOUTS:
                rc = mdc_ioc_swap_layouts(exp, karg);
-               break;
+               GOTO(out, rc);
+       default:
+               CERROR("unrecognised ioctl: cmd = %#x\n", cmd);
+               GOTO(out, rc = -ENOTTY);
        }
-        default:
-                CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
-                GOTO(out, rc = -ENOTTY);
-        }
 out:
-        cfs_module_put(THIS_MODULE);
+       cfs_module_put(THIS_MODULE);
 
-        return rc;
+       return rc;
 }
 
 int mdc_get_info_rpc(struct obd_export *exp,