The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=c402edf86e0aea097fbdead3f6c0eafed62492e0
commit c402edf86e0aea097fbdead3f6c0eafed62492e0 Author: Bjoern A. Zeeb <[email protected]> AuthorDate: 2026-10-12 00:19:17 +0000 Commit: Bjoern A. Zeeb <[email protected]> CommitDate: 2026-12-04 16:35:51 +0000 LinuxKPI: firmware: ensure name stays valid The name argument passed into request_firmware_nowait() may only be valid locally in the calling function and could be out of scope by the time the task runs; make a copy to ensure it stays valid over the callback. MFC after: 3 days Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D60630 --- sys/compat/linuxkpi/common/src/linux_firmware.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/src/linux_firmware.c b/sys/compat/linuxkpi/common/src/linux_firmware.c index 0d8f9b770d70..f713f265d9de 100644 --- a/sys/compat/linuxkpi/common/src/linux_firmware.c +++ b/sys/compat/linuxkpi/common/src/linux_firmware.c @@ -39,6 +39,7 @@ #include <linux/types.h> #include <linux/device.h> +#include <linux/string.h> #include <linux/firmware.h> #undef firmware @@ -166,6 +167,8 @@ lkpi_fw_task(void *ctx, int pending) /* Do not assume fw is still valid! */ out: + if (lfwt->fw_name != NULL) + kfree_const(lfwt->fw_name); free(lfwt, M_LKPI_FW); } @@ -178,8 +181,12 @@ linuxkpi_request_firmware_nowait(struct module *mod __unused, bool _t __unused, int error; lfwt = malloc(sizeof(*lfwt), M_LKPI_FW, M_WAITOK | M_ZERO); + lfwt->fw_name = kstrdup_const(fw_name, gfp); + if (lfwt->fw_name == NULL) { + free(lfwt, M_LKPI_FW); + return (-ENOMEM); + } lfwt->gfp = gfp; - lfwt->fw_name = fw_name; lfwt->dev = dev; lfwt->drv = drv; lfwt->cont = cont;
