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(). Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hector Martin <marcan@marcan.st> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20220131160713.245637-8-marcan@marcan.st
This commit is contained in:
parent
b50255c83b
commit
9cf6d7f2c5
@ -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] = '-';
|
||||
|
Loading…
Reference in New Issue
Block a user