broadcom: brcmfmac, alloc without null test

Message ID 7658242ceef838cc553cb3bbb63ede20d1bf9cb5.camel@perches.com
State New
Headers
Series broadcom: brcmfmac, alloc without null test |

Commit Message

Joe Perches Feb. 17, 2024, 7:40 p.m. UTC
  There's a missing NULL alloc test here:

It doesn't appear obvious what a proper fix is.
  

Comments

Arend van Spriel Feb. 18, 2024, 8:26 a.m. UTC | #1
On 2/17/2024 8:40 PM, Joe Perches wrote:
> There's a missing NULL alloc test here:
> 
> It doesn't appear obvious what a proper fix is.
> 
> diff -u -p ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> --- ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> +++ /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
> @@ -4308,7 +4308,6 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp,
>   	int ret;
>   
>   	pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL);

Thanks, Joe

Looking at the callers I would say returning -ENOMEM here when pmk_op is 
NULL should do the trick.

Regards,
Arend

> -	pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3);
>   
>   	if (!pmksa) {
>   		/* Flush operation, operate on entire list */
>
  

Patch

diff -u -p ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
--- ./drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ /tmp/nothing/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4308,7 +4308,6 @@  brcmf_pmksa_v3_op(struct brcmf_if *ifp,
 	int ret;
 
 	pmk_op = kzalloc(sizeof(*pmk_op), GFP_KERNEL);
-	pmk_op->version = cpu_to_le16(BRCMF_PMKSA_VER_3);
 
 	if (!pmksa) {
 		/* Flush operation, operate on entire list */