From 0d166ef1fd80b0056497969b956d04e32e86aa85 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Fri, 12 Jul 2013 10:21:48 -0500 Subject: [PATCH] LU-3576 mdc: prevent fall through in mdc_iocontrol() 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. Signed-off-by: John L. Hammond Change-Id: Ib3c04835f8cd761849869c8fb11672d66aa14025 Reviewed-on: http://review.whamcloud.com/6962 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Aurelien Degremont Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Oleg Drokin --- lustre/mdc/mdc_request.c | 61 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 50f9600..f318474 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1836,6 +1836,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); @@ -1904,44 +1905,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 (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 (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, -- 1.8.3.1