Skip to content
Permalink
Browse files
brcmfmac: of: Use devm_kstrdup for board_type & check for errors
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>
  • Loading branch information
marcan committed Jan 18, 2022
1 parent df0a2c4 commit cc44c86950084bc3437485288390841cf117c0d1
Showing 1 changed file with 6 additions and 2 deletions.
@@ -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] = '-';

0 comments on commit cc44c86

Please sign in to comment.