malloc error handling moved into one place. Signed-off-by: Ivan Safonov <insafonov@xxxxxxxxx> --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 67 +++++++------------------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 80c602e..c600a7e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -564,31 +564,19 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra n struct setopmode_parm *psetop; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { - res = false; - goto exit; - } psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL); - - if (psetop == NULL) { + if (!ph2c || !psetop) { kfree(ph2c); - res = false; - goto exit; + kfree(psetop); + return false; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); psetop->mode = (u8)networktype; - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - - return res; + return rtw_enqueue_cmd(pcmdpriv, ph2c); } u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) @@ -601,28 +589,16 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct sta_info *sta = (struct sta_info *)psta; - u8 res = _SUCCESS; - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); - if (psetstakey_para == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL); - if (psetstakey_rsp == NULL) { + + if (!ph2c || !psetstakey_para || !psetstakey_rsp) { kfree(ph2c); kfree(psetstakey_para); - res = _FAIL; - goto exit; + kfree(psetstakey_rsp); + return _FAIL; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); @@ -644,12 +620,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) /* jeff: set this because at least sw key is ready */ padapter->securitypriv.busetkipkey = true; - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - - return res; + return rtw_enqueue_cmd(pcmdpriv, ph2c); } u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) @@ -1080,31 +1051,19 @@ u8 rtw_ps_cmd(struct adapter *padapter) struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ppscmd == NULL) { - res = _FAIL; - goto exit; - } - pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!ppscmd || !pdrvextra_cmd_parm) { kfree(ppscmd); - res = _FAIL; - goto exit; + kfree(pdrvextra_cmd_parm); + return _FAIL; } pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; pdrvextra_cmd_parm->pbuf = NULL; init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - res = rtw_enqueue_cmd(pcmdpriv, ppscmd); - -exit: - - - return res; + return rtw_enqueue_cmd(pcmdpriv, ppscmd); } #ifdef CONFIG_88EU_AP_MODE -- 2.4.10 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel