Re: [PATCH] wifi: brcmfmac: Replace strlcat() with snprintf() in brcmf_fw_alloc_request()
From: Mariia Nikitash
Date: Wed Dec 02 2026 - 18:53:21 EST
Hi Arend,
Thanks for the feedback!
On Tue, Nov 17, 2026 at 5:31 AM Arend van Spriel
<arend.vanspriel@xxxxxxxxxxxx> wrote:
>
> On Tue, 13 Oct 2026 17:55:52 -0700, Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx> wrote:
> > From: Bill Wendling <morbo@xxxxxxxxxx>
> >
> > brcmf_fw_alloc_request() constructs firmware file paths by chaining
> > strscpy() and multiple strlcat() calls for the module parameter path,
> > separator, base name, and extension.
> >
> > In preparation for removing the deprecated strlcat() API[1], format the
> > complete firmware path in a single snprintf() call.
> >
> > Link: https://github.com/KSPP/linux/issues/370 [1]
> > Cc: codemender-patching+linux@xxxxxxxxxx
> > Assisted-by: LLM
>
> Is this Cc: line necessary? Can you clarify its purpose? No need to clarify
> in the commit message. Just an email response will do.
I'm shepherding this patch from Bill's larger strlcat() removal series
[1], and the Cc tag was inherited from his original submission. I'll
drop it in v2.
>
> The Assisted-by: tag shows this change was produced with an LLM. Please
> follow the guidelines in Documentation/process/generated-content.rst so
> it is clear what was tool generated and what tool and/or LLM was used.
The initial implementation was developed with the assistance of
Google's CodeMender agent. I added Assisted-by tag in accordance with
the guidelines at the time of submission. I'll drop the obsolete tag
and clarify the tooling assistance in the v2 changelog.
>
> [...]
>
> > for (j = 0; j < n_fwnames; j++) {
> > - fwreq->items[j].path = fwnames[j].path;
> > - fwnames[j].path[0] = '\0';
> > /* check if firmware path is provided by module parameter */
> > if (brcmf_mp_global.firmware_path[0] != '\0') {
> > - strscpy(fwnames[j].path, mp_path,
> > - BRCMF_FW_NAME_LEN);
> > -
> > - if (end != '/') {
> > - strlcat(fwnames[j].path, "/",
> > - BRCMF_FW_NAME_LEN);
> > - }
> > + snprintf(fwnames[j].path, BRCMF_FW_NAME_LEN, "%s%s%s%s",
> > + mp_path, (end == '/') ? "" : "/",
> > + mapping_table[i].fw_base,
> > + fwnames[j].extension);
> > + } else {
> > + snprintf(fwnames[j].path, BRCMF_FW_NAME_LEN, "%s%s",
> > + mapping_table[i].fw_base,
> > + fwnames[j].extension);
> > }
> > - strlcat(fwnames[j].path, mapping_table[i].fw_base,
> > - BRCMF_FW_NAME_LEN);
> > - strlcat(fwnames[j].path, fwnames[j].extension,
> > - BRCMF_FW_NAME_LEN);
> > fwreq->items[j].path = fwnames[j].path;
> > }
>
> Please address Kees' comment and collapse this into a single snprintf().
> Note mp_path points to the firmware_path array so it can never be NULL; an
> empty mp_path simply prints nothing, so something like the following would do:
>
> snprintf(fwnames[j].path, BRCMF_FW_NAME_LEN, "%s%s%s%s", mp_path,
> (mp_path_len && end != '/') ? "/" : "",
> mapping_table[i].fw_base, fwnames[j].extension);
Thanks, Kees and Arend! I'll consolidate the two snprintf() as
suggested while preserving the empty firmware path behavior.
>
> Regards,
> Arend
Best,
Mariia
[1] https://lore.kernel.org/all/20260915081910.4142719-1-morbo@xxxxxxxxxx/