diff options
author | Justin Stitt <justinstitt@google.com> | 2024-03-06 00:34:38 +0100 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2024-03-10 23:37:43 +0100 |
commit | 2303149d584feade8074295b717451b36ac63307 (patch) | |
tree | 0f3fd40e9b409d815571e52a0cdbd152a5c19036 /drivers/net/ethernet/qlogic | |
parent | scsi: mpt3sas: Replace deprecated strncpy() with strscpy() (diff) | |
download | linux-2303149d584feade8074295b717451b36ac63307.tar.xz linux-2303149d584feade8074295b717451b36ac63307.zip |
scsi: qedf: Replace deprecated strncpy() with strscpy()
We expect slowpath_params.name to be NUL-terminated based on its future
usage with other string APIs:
| static int qed_slowpath_start(struct qed_dev *cdev,
| struct qed_slowpath_params *params)
...
| strscpy(drv_version.name, params->name,
| MCP_DRV_VER_STR_SIZE - 4);
Moreover, NUL-padding is not necessary as the only use for this slowpath
name parameter is to copy into the drv_version.name field.
Also, let's prefer using strscpy(src, dest, sizeof(src)) in two instances
(one of which is outside of the scsi system but it is trivial and related
to this patch).
We can see the drv_version.name size here:
| struct qed_mcp_drv_version {
| u32 version;
| u8 name[MCP_DRV_VER_STR_SIZE - 4];
| };
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Justin Stitt <justinstitt@google.com>
Link: https://lore.kernel.org/r/20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-3-5b78a13ff984@google.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/net/ethernet/qlogic')
-rw-r--r-- | drivers/net/ethernet/qlogic/qed/qed_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c index c278f8893042..d39e198fe8db 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_main.c +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c @@ -1351,7 +1351,7 @@ static int qed_slowpath_start(struct qed_dev *cdev, (params->drv_rev << 8) | (params->drv_eng); strscpy(drv_version.name, params->name, - MCP_DRV_VER_STR_SIZE - 4); + sizeof(drv_version.name)); rc = qed_mcp_send_drv_version(hwfn, hwfn->p_main_ptt, &drv_version); if (rc) { |