diff options
author | Oded Gabbay <ogabbay@kernel.org> | 2021-04-03 16:37:29 +0300 |
---|---|---|
committer | Oded Gabbay <ogabbay@kernel.org> | 2021-04-09 14:09:24 +0300 |
commit | ae382c22fc06058b24bb49c92f3b0af653499589 (patch) | |
tree | adcd13634432627e0ad8f7bed83c0b991ee84e01 /drivers/misc | |
parent | 131d1ba1304a9a2040648cb03309d9444e7fe45f (diff) | |
download | linux-ae382c22fc06058b24bb49c92f3b0af653499589.tar.bz2 |
habanalabs: use strscpy instead of sprintf and strlcpy
Prefer the use of strscpy when copying the ASIC name into a char array,
to prevent accidentally exceeding the array's length.
In addition, strlcpy is frowned upon so replace it.
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/habanalabs/common/device.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c index e64c60d48d42..2ed4f2bedc08 100644 --- a/drivers/misc/habanalabs/common/device.c +++ b/drivers/misc/habanalabs/common/device.c @@ -321,11 +321,11 @@ static int device_early_init(struct hl_device *hdev) switch (hdev->asic_type) { case ASIC_GOYA: goya_set_asic_funcs(hdev); - strlcpy(hdev->asic_name, "GOYA", sizeof(hdev->asic_name)); + strscpy(hdev->asic_name, "GOYA", sizeof(hdev->asic_name)); break; case ASIC_GAUDI: gaudi_set_asic_funcs(hdev); - sprintf(hdev->asic_name, "GAUDI"); + strscpy(hdev->asic_name, "GAUDI", sizeof(hdev->asic_name)); break; default: dev_err(hdev->dev, "Unrecognized ASIC type %d\n", |