Re: [PATCH v3 1/4] staging: rtl8723bs: replace _rtw_malloc with kmalloc

From: Andy Shevchenko

Date: Wed Jan 28 2026 - 16:51:52 EST


On Wed, Jan 28, 2026 at 11:09:51PM +0900, Minu Jin wrote:
> Remove wrapper function _rtw_malloc and macro rtw_malloc.
> Replace all rtw_malloc with kmalloc.
>
> All call sites are reviewed to select GFP_KERNEL or GFP_ATOMIC.
>
> 1. GFP_KERNEL:
> Used in paths that are executed in process context and are allowed to sleep.
>
> - Driver initialization and probe paths.
> - Workqueue callbacks and cfg80211 configuration callbacks.
>
> 2. GFP_ATOMIC:
> Used in paths that must not sleep because they operate in atomic contexts.
>
> - Interrupt handlers and SoftIRQ contexts.
> - Functions called while holding spinlocks.
> - Low-level I/O operations (SDIO) (eg, sdio_read32())

...

> static void update_BCNTIM(struct adapter *padapter)

> if (remainder_ielen > 0) {
> - pbackup_remainder_ie = rtw_malloc(remainder_ielen);
> + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);
> if (pbackup_remainder_ie && premainder_ie)
> memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);

I haven't read the code in full, but why not

if (premainder_ie)
pbackup_remainder_ie = kmemdup(rpremainder_ie, emainder_ielen, GFP_ATOMIC);
else
pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);

> }

...

> static void update_bcn_wps_ie(struct adapter *padapter)

> if (remainder_ielen > 0) {
> - pbackup_remainder_ie = rtw_malloc(remainder_ielen);
> + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC);
> if (pbackup_remainder_ie)
> memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);

This is simply kmemdup().

> }

...

Also check other places if they are copying existing data.

--
With Best Regards,
Andy Shevchenko