Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757487AbbKFPSu (ORCPT ); Fri, 6 Nov 2015 10:18:50 -0500 Received: from mail-lf0-f44.google.com ([209.85.215.44]:34520 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbbKFPSs (ORCPT ); Fri, 6 Nov 2015 10:18:48 -0500 Date: Fri, 6 Nov 2015 22:20:17 +0700 From: Ivan Safonov To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman , Ivan Safonov , Larry Finger , Vaishali Thakkar , Bryan Paul , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] staging: rtl8188eu: goto removed Message-ID: <20151106152017.GA12152@alpha.sfu-kras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3711 Lines: 138 malloc error handling moved into one place. Signed-off-by: Ivan Safonov --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/