Commit 9577f3b3 authored by Minu Jin's avatar Minu Jin Committed by Greg Kroah-Hartman
Browse files

staging: rtl8723bs: replace rtw_malloc() with kmalloc()



Replace the wrapper function rtw_malloc() with standard kmalloc().
Call sites were reviewed to use appropriate GFP flags (GFP_KERNEL or
GFP_ATOMIC) based on the execution context.

About GFP Flags:
- GFP_ATOMIC is used for allocations in atomic contexts such as
  spinlock-protected sections, tasklets, and timer handlers.
- GFP_KERNEL is used for process contexts where sleeping is allowed.

Also, convert error return codes from -1 to -ENOMEM where appropriate.

Signed-off-by: default avatarMinu Jin <s9430939@naver.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@intel.com>
Link: https://patch.msgid.link/20260204131347.3515949-3-s9430939@naver.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5ed9ef27
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1695,7 +1695,7 @@ static void c2h_wk_callback(struct work_struct *work)
			/* This C2H event is read, clear it */
			c2h_evt_clear(adapter);
		} else {
			c2h_evt = rtw_malloc(16);
			c2h_evt = kmalloc(16, GFP_ATOMIC);
			if (c2h_evt) {
				/* This C2H event is not read, read & clear now */
				if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) {
+1 −1
Original line number Diff line number Diff line
@@ -586,7 +586,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame)
	if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) {
		if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) {
			/* we should update current network before auth, or some IE is wrong */
			pbss = rtw_malloc(sizeof(struct wlan_bssid_ex));
			pbss = kmalloc(sizeof(*pbss), GFP_ATOMIC);
			if (pbss) {
				if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) {
					update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true);
+2 −2
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ static void hal_ReadEFuse_WiFi(
	if ((_offset + _size_byte) > EFUSE_MAX_MAP_LEN)
		return;

	efuseTbl = rtw_malloc(EFUSE_MAX_MAP_LEN);
	efuseTbl = kmalloc(EFUSE_MAX_MAP_LEN, GFP_ATOMIC);
	if (!efuseTbl)
		return;

@@ -728,7 +728,7 @@ static void hal_ReadEFuse_BT(
	if ((_offset + _size_byte) > EFUSE_BT_MAP_LEN)
		return;

	efuseTbl = rtw_malloc(EFUSE_BT_MAP_LEN);
	efuseTbl = kmalloc(EFUSE_BT_MAP_LEN, GFP_ATOMIC);
	if (!efuseTbl)
		return;

+12 −12
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr)
	} else {
		u8 *tmpbuf;

		tmpbuf = rtw_malloc(8);
		tmpbuf = kmalloc(8, GFP_ATOMIC);
		if (!tmpbuf)
			return SDIO_ERR_VAL32;

@@ -228,9 +228,9 @@ static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)

		ftaddr &= ~(u16)0x3;
		n = cnt + shift;
		tmpbuf = rtw_malloc(n);
		tmpbuf = kmalloc(n, GFP_ATOMIC);
		if (!tmpbuf)
			return -1;
			return -ENOMEM;

		err = sd_read(intfhdl, ftaddr, n, tmpbuf);
		if (!err)
@@ -331,9 +331,9 @@ static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf)

		ftaddr &= ~(u16)0x3;
		n = cnt + shift;
		tmpbuf = rtw_malloc(n);
		tmpbuf = kmalloc(n, GFP_ATOMIC);
		if (!tmpbuf)
			return -1;
			return -ENOMEM;
		err = sd_read(intfhdl, ftaddr, 4, tmpbuf);
		if (err) {
			kfree(tmpbuf);
@@ -503,9 +503,9 @@ static s32 _sdio_local_read(
		return _sd_cmd52_read(intfhdl, addr, cnt, buf);

	n = round_up(cnt, 4);
	tmpbuf = rtw_malloc(n);
	tmpbuf = kmalloc(n, GFP_ATOMIC);
	if (!tmpbuf)
		return -1;
		return -ENOMEM;

	err = _sd_read(intfhdl, addr, n, tmpbuf);
	if (!err)
@@ -544,9 +544,9 @@ s32 sdio_local_read(
		return sd_cmd52_read(intfhdl, addr, cnt, buf);

	n = round_up(cnt, 4);
	tmpbuf = rtw_malloc(n);
	tmpbuf = kmalloc(n, GFP_ATOMIC);
	if (!tmpbuf)
		return -1;
		return -ENOMEM;

	err = sd_read(intfhdl, addr, n, tmpbuf);
	if (!err)
@@ -583,9 +583,9 @@ s32 sdio_local_write(
	)
		return sd_cmd52_write(intfhdl, addr, cnt, buf);

	tmpbuf = rtw_malloc(cnt);
	tmpbuf = kmalloc(cnt, GFP_ATOMIC);
	if (!tmpbuf)
		return -1;
		return -ENOMEM;

	memcpy(tmpbuf, buf, cnt);

@@ -883,7 +883,7 @@ void sd_int_dpc(struct adapter *adapter)
		u8 *status;
		u32 addr;

		status = rtw_malloc(4);
		status = kmalloc(4, GFP_ATOMIC);
		if (status) {
			addr = REG_TXDMA_STATUS;
			hal_sdio_get_cmd_addr_8723b(adapter, WLAN_IOREG_DEVICE_ID, addr, &addr);