From 0a5b53c1e7276ffacf5153d06d442c4d7ab0c41d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 28 Sep 2026 02:00:29 -0700 Subject: [PATCH] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() bfa_fcs_fabric_nsymb_init() constructs the node symbolic name using strscpy() followed by five strlcat() calls and explicit NUL-termination. In preparation for removing the deprecated strlcat() API[1], replace the chained string copies with a single snprintf() call. Link: https://github.com/KSPP/linux/issues/370 [1] Cc: codemender-patching+linux@google.com Assisted-by: LLM Signed-off-by: Bill Wendling Signed-off-by: Mariia Nikitash Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20260928090031.712418-2-nikitash.mariiaw@gmail.com Signed-off-by: Martin K. Petersen (Oracle) --- drivers/scsi/bfa/bfa_fcs.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c index 9b57312f43f5..7a4e0e8c7182 100644 --- a/drivers/scsi/bfa/bfa_fcs.c +++ b/drivers/scsi/bfa/bfa_fcs.c @@ -821,30 +821,13 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric) bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model); - /* Model name/number */ - strscpy(port_cfg->node_sym_name.symname, model, - BFA_SYMNAME_MAXLEN); - strlcat(port_cfg->node_sym_name.symname, - BFA_FCS_PORT_SYMBNAME_SEPARATOR, - BFA_SYMNAME_MAXLEN); - - /* Driver Version */ - strlcat(port_cfg->node_sym_name.symname, (char *)driver_info->version, - BFA_SYMNAME_MAXLEN); - strlcat(port_cfg->node_sym_name.symname, - BFA_FCS_PORT_SYMBNAME_SEPARATOR, - BFA_SYMNAME_MAXLEN); - - /* Host machine name */ - strlcat(port_cfg->node_sym_name.symname, - driver_info->host_machine_name, - BFA_SYMNAME_MAXLEN); - strlcat(port_cfg->node_sym_name.symname, - BFA_FCS_PORT_SYMBNAME_SEPARATOR, - BFA_SYMNAME_MAXLEN); - - /* null terminate */ - port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0; + /* Model name/number, Driver Version, Host machine name */ + snprintf(port_cfg->node_sym_name.symname, BFA_SYMNAME_MAXLEN, + "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR + "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR + "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR, + model, (char *)driver_info->version, + driver_info->host_machine_name); } /*