mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code
@ 2024-08-21  2:33 Jinjie Ruan
  2024-08-21  3:42 ` Ping-Ke Shih
  2024-08-21  5:48 ` Arend Van Spriel
  0 siblings, 2 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-21  2:33 UTC (permalink / raw)
  To: arend.vanspriel, kvalo, johannes.berg, emmanuel.grumbach,
	ruanjinjie, erick.archer, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-kernel

Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.

No functional change.

Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c | 3 +--
 1 file changed, 1 insertion(+), 2 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..7717d7764d2d 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 0;
 			}
 		}
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code
  2024-08-21  2:33 [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code Jinjie Ruan
@ 2024-08-21  3:42 ` Ping-Ke Shih
  2024-08-21  5:48 ` Arend Van Spriel
  1 sibling, 0 replies; 4+ messages in thread
From: Ping-Ke Shih @ 2024-08-21  3:42 UTC (permalink / raw)
  To: Jinjie Ruan, arend.vanspriel, kvalo, johannes.berg,
	emmanuel.grumbach, erick.archer, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-kernel

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>
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c | 3 +--

Subject prefix should be "wifi: brcmsmac:".



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code
  2024-08-21  2:33 [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code Jinjie Ruan
  2024-08-21  3:42 ` Ping-Ke Shih
@ 2024-08-21  5:48 ` Arend Van Spriel
  2024-08-21  6:43   ` Jinjie Ruan
  1 sibling, 1 reply; 4+ messages in thread
From: Arend Van Spriel @ 2024-08-21  5:48 UTC (permalink / raw)
  To: Jinjie Ruan, kvalo, johannes.berg, emmanuel.grumbach,
	erick.archer, linux-wireless, brcm80211, brcm80211-dev-list.pdl,
	linux-kernel

On August 21, 2024 4:26:17 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:

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

Comment below...

> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
> drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c | 3 +--
> 1 file changed, 1 insertion(+), 2 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..7717d7764d2d 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;

This is the only jump to fail: so instead simply return here with -ENOMEM 
and remove the fail: label.

Regards,
Arend

> - memcpy(*pbuf, pdata, len);
>  return 0;
>  }
>  }
> --
> 2.34.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code
  2024-08-21  5:48 ` Arend Van Spriel
@ 2024-08-21  6:43   ` Jinjie Ruan
  0 siblings, 0 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-08-21  6:43 UTC (permalink / raw)
  To: Arend Van Spriel, kvalo, johannes.berg, emmanuel.grumbach,
	erick.archer, linux-wireless, brcm80211, brcm80211-dev-list.pdl,
	linux-kernel



On 2024/8/21 13:48, Arend Van Spriel wrote:
> On August 21, 2024 4:26:17 AM Jinjie Ruan <ruanjinjie@huawei.com> wrote:
> 
>> Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code.
>>
>> No functional change.
> 
> Comment below...
> 
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>> drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 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..7717d7764d2d 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;
> 
> This is the only jump to fail: so instead simply return here with
> -ENOMEM and remove the fail: label.

Right. Thank you!

> 
> Regards,
> Arend
> 
>> - memcpy(*pbuf, pdata, len);
>>  return 0;
>>  }
>>  }
>> -- 
>> 2.34.1
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-21  6:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-21  2:33 [PATCH -next] wifi: mac80211: Use kvmemdup to simplify the code Jinjie Ruan
2024-08-21  3:42 ` Ping-Ke Shih
2024-08-21  5:48 ` Arend Van Spriel
2024-08-21  6:43   ` Jinjie Ruan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®