Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e2b0aae authored by Larry Finger's avatar Larry Finger Committed by Greg Kroah-Hartman
Browse files

staging: rtl8723bs: Fix potential usage while NULL error in hal/rtl8723b_hal_init.c



Smatch logs the following:

  CHECK   drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:518 rtl8723b_FirmwareDownload() error: we previously assumed 'pFirmware' could be null (see line 382)

Fixing this error required a rewrite of the error exits from this routine.

Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6557ddfe
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -377,13 +377,13 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
	RT_TRACE(_module_hal_init_c_, _drv_notice_, ("+%s, bUsedWoWLANFw:%d\n", __func__, bUsedWoWLANFw));
	RT_TRACE(_module_hal_init_c_, _drv_notice_, ("+%s, bUsedWoWLANFw:%d\n", __func__, bUsedWoWLANFw));
#endif
#endif
	pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
	pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
	if (!pFirmware)
		return _FAIL;
	pBTFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);
	pBTFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL);

	if (!pBTFirmware) {
	if (!pFirmware || !pBTFirmware) {
		kfree(pFirmware);
		rtStatus = _FAIL;
		return _FAIL;
		goto exit;
	}
	}

	tmp_ps = rtw_read8(padapter, 0xa3);
	tmp_ps = rtw_read8(padapter, 0xa3);
	tmp_ps &= 0xf8;
	tmp_ps &= 0xf8;
	tmp_ps |= 0x02;
	tmp_ps |= 0x02;
@@ -441,7 +441,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
	if (pFirmware->ulFwLength > FW_8723B_SIZE) {
	if (pFirmware->ulFwLength > FW_8723B_SIZE) {
		rtStatus = _FAIL;
		rtStatus = _FAIL;
		DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", pFirmware->ulFwLength, FW_8723B_SIZE);
		DBG_871X_LEVEL(_drv_emerg_, "Firmware size:%u exceed %u\n", pFirmware->ulFwLength, FW_8723B_SIZE);
		goto exit;
		goto release_fw1;
	}
	}


	pFirmwareBuf = pFirmware->szFwBuffer;
	pFirmwareBuf = pFirmware->szFwBuffer;
@@ -517,6 +517,7 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw)
exit:
exit:
	kfree(pFirmware->szFwBuffer);
	kfree(pFirmware->szFwBuffer);
	kfree(pFirmware);
	kfree(pFirmware);
release_fw1:
	kfree(pBTFirmware);
	kfree(pBTFirmware);
	DBG_871X(" <=== rtl8723b_FirmwareDownload()\n");
	DBG_871X(" <=== rtl8723b_FirmwareDownload()\n");
	return rtStatus;
	return rtStatus;