[PATCH -next v2] wifi: brcmsmac: Use kvmemdup to simplify the code

Jinjie Ruan posted 1 patch 1 year, 5 months ago
.../net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c  | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH -next v2] wifi: brcmsmac: Use kvmemdup to simplify the code
Posted by Jinjie Ruan 1 year, 5 months ago
Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.

No functional change.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
v2:
- Update the commit subject.
- Remove goto lablel and retun -ENOMEM instead.
---
 .../net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c  | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
index d86f28b8bc60..5b1d35601bbd 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
@@ -1611,10 +1611,9 @@ int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx)
 			if (le32_to_cpu(hdr->idx) == idx) {
 				pdata = wl->fw.fw_bin[i]->data +
 					le32_to_cpu(hdr->offset);
-				*pbuf = kvmalloc(len, GFP_KERNEL);
+				*pbuf = kvmemdup(pdata, len, GFP_KERNEL);
 				if (*pbuf == NULL)
-					goto fail;
-				memcpy(*pbuf, pdata, len);
+					return -ENOMEM;
 				return 0;
 			}
 		}
@@ -1622,7 +1621,6 @@ int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx)
 	brcms_err(wl->wlc->hw->d11core,
 		  "ERROR: ucode buf tag:%d can not be found!\n", idx);
 	*pbuf = NULL;
-fail:
 	return -ENODATA;
 }
 
-- 
2.34.1
Re: [PATCH -next v2] wifi: brcmsmac: Use kvmemdup to simplify the code
Posted by Kalle Valo 1 year, 5 months ago
Jinjie Ruan <ruanjinjie@huawei.com> wrote:

> Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.
> 
> No functional change.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>

Patch applied to wireless-next.git, thanks.

d38792292be7 wifi: brcmsmac: Use kvmemdup to simplify the code

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240821070257.2298559-1-ruanjinjie@huawei.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
https://docs.kernel.org/process/submitting-patches.html
Re: [PATCH -next v2] wifi: brcmsmac: Use kvmemdup to simplify the code
Posted by Arend Van Spriel 1 year, 5 months ago
On August 21, 2024 8:55:44 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:

> Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.
>
> No functional change.

Thanks

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> v2:
> - Update the commit subject.
> - Remove goto lablel and retun -ENOMEM instead.
> ---
> .../net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c  | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)