diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2023-09-04 21:18:36 +0200 |
---|---|---|
committer | Oded Gabbay <ogabbay@kernel.org> | 2023-10-09 12:37:20 +0300 |
commit | 90f3de616259cbb5666f00f8daf5420cd7d71d18 (patch) | |
tree | 24ce58e02d8035ea04e984ac19f26d8630984ee8 /drivers/accel/habanalabs | |
parent | a45d5cf09d49ed46c1cf1150ed5a891878a161f3 (diff) | |
download | linux-stable-90f3de616259cbb5666f00f8daf5420cd7d71d18.tar.gz linux-stable-90f3de616259cbb5666f00f8daf5420cd7d71d18.tar.bz2 linux-stable-90f3de616259cbb5666f00f8daf5420cd7d71d18.zip |
accel/habanalabs/gaudi2: Fix incorrect string length computation in gaudi2_psoc_razwi_get_engines()
snprintf() returns the "number of characters which *would* be generated for
the given input", not the size *really* generated.
In order to avoid too large values for 'str_size' (and potential negative
values for "PSOC_RAZWI_ENG_STR_SIZE - str_size") use scnprintf()
instead of snprintf().
Fixes: c0e6df916050 ("accel/habanalabs: fix address decode RAZWI handling")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/accel/habanalabs')
-rw-r--r-- | drivers/accel/habanalabs/gaudi2/gaudi2.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/accel/habanalabs/gaudi2/gaudi2.c b/drivers/accel/habanalabs/gaudi2/gaudi2.c index e53de95b1791..d60389b6700f 100644 --- a/drivers/accel/habanalabs/gaudi2/gaudi2.c +++ b/drivers/accel/habanalabs/gaudi2/gaudi2.c @@ -8278,11 +8278,11 @@ static int gaudi2_psoc_razwi_get_engines(struct gaudi2_razwi_info *razwi_info, u eng_id[num_of_eng] = razwi_info[i].eng_id; base[num_of_eng] = razwi_info[i].rtr_ctrl; if (!num_of_eng) - str_size += snprintf(eng_name + str_size, + str_size += scnprintf(eng_name + str_size, PSOC_RAZWI_ENG_STR_SIZE - str_size, "%s", razwi_info[i].eng_name); else - str_size += snprintf(eng_name + str_size, + str_size += scnprintf(eng_name + str_size, PSOC_RAZWI_ENG_STR_SIZE - str_size, " or %s", razwi_info[i].eng_name); num_of_eng++; |