Thread (17 messages) 17 messages, 4 authors, 2022-02-01
STALE1587d LANDED: 2 (1M)
Revisions (2)
  1. v3 [diff vs current]
  2. v4 current

[PATCH v4 7/9] brcmfmac: of: Use devm_kstrdup for board_type & check for errors

From: Hector Martin <hidden>
Date: 2022-01-31 16:09:51
Also in: linux-acpi, linux-devicetree, linux-wireless, lkml
Subsystem: broadcom brcm80211 ieee802.11 wireless drivers, the rest · Maintainers: Arend van Spriel, Linus Torvalds

This was missing a NULL check, and we can collapse the strlen/alloc/copy
into a devm_kstrdup().

Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Reviewed-by: Andy Shevchenko <redacted>
Signed-off-by: Hector Martin <redacted>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 7 +++++--
 1 file changed, 5 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..5708de1d9f26 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
@@ -79,8 +79,11 @@ 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) {
+			of_node_put(root);
+			return;
+		}
 		for (i = 0; i < board_type[i]; i++) {
 			if (board_type[i] == '/')
 				board_type[i] = '-';
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help