brcmfmac: check the return value of devm_kzalloc() in brcmf_of_probe()
PATCH v2 1/1 brcmfmac: check the return value of devm_kzalloc() in brcmf_of_probe()
The function devm_kzalloc() in brcmf_of_probe() can fail, so its return value should be checked.
---
v2:
* Add of_node_put() in error handling path.
Thank Kalle for good advice.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c +4 -0
@@ -80,6 +80,10 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,/* get rid of '/' in the compatible string to be able to find the FW */ len =strlen (tmp) +1 ; board_type =devm_kzalloc (dev, len,GFP_KERNEL ); +if (!board_type) { +of_node_put (root); +return ; + }strscpy (board_type, tmp, len);for (i =0 ; i < board_type[i]; i++) {if (board_type[i] =='/' )
Signature · 1 line
2.17.1
Quoted 6 lines · Jia-Ju Bai
The function
devm_kzalloc()inbrcmf_of_probe()can fail, so its return value should be checked.Fixes 29e354ebeeec ("brcmfmac: Transform compatible string for FW loading")Reported-by TOTE Robot <[email protected]>Signed-off-by Jia-Ju Bai <[email protected]>
Fails to apply to wireless-next:
Recorded preimage for 'drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c'
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: brcmfmac: check the return value of devm_kzalloc() in brcmf_of_probe() Using index info to reconstruct a base tree...
M drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
CONFLICT (content): Merge conflict in drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c Patch failed at 0001 brcmfmac: check the return value of devm_kzalloc() in brcmf_of_probe()
Patch set to Changes Requested.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches