lkml.org 
[lkml]   [2022]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 7/9] brcmfmac: of: Use devm_kstrdup for board_type & check for errors
Date
This was missing a NULL check, and we can collapse the strlen/alloc/copy
into a devm_kstrdup().

Signed-off-by: Hector Martin <marcan@marcan.st>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
index 513c7e6421b2..5dc1e942e9e7 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
@@ -79,8 +79,12 @@ 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);
- strscpy(board_type, tmp, len);
+ board_type = devm_kstrdup(dev, tmp, GFP_KERNEL);
+ if (!board_type) {
+ brcmf_err("out of memory allocating board_type\n");
+ of_node_put(root);
+ return;
+ }
for (i = 0; i < board_type[i]; i++) {
if (board_type[i] == '/')
board_type[i] = '-';
--
2.33.0
\
 
 \ /
  Last update: 2022-01-17 15:32    [W:0.398 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site