Re: [PATCH] wifi: brcmfmac: Replace strlcat() with snprintf() in brcmf_fw_alloc_request()
From: Arend van Spriel
Date: Tue Nov 17 2026 - 08:32:05 EST
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.
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.
[...]
> 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);
Regards,
Arend