lkml.org 
[lkml]   [2022]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 7/9] brcmfmac: of: Use devm_kstrdup for board_type & check for errors
On Mon, Jan 17, 2022 at 4:31 PM Hector Martin <marcan@marcan.st> wrote:
>
> This was missing a NULL check, and we can collapse the strlen/alloc/copy
> into a devm_kstrdup().

Nice patch. After dropping the message,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> /* 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] = '-';

Next step is to replace this with NIH strreplace()

And
of_property_read_string_index(root, "compatible", 0, &tmp);
with
of_property_read_string(root, "compatible", &tmp);

And might add an error check, but I believe if there is no compatible
property present, this can't be called.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-01-20 11:54    [W:0.246 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site