mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-16 23:45:31 +08:00
accel/habanalabs/gaudi2: Fix incorrect string length computation in gaudi2_psoc_razwi_get_engines()
[ Upstream commit90f3de6162
] 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:c0e6df9160
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
12d322fc6e
commit
a5d2bb064c
@ -8149,11 +8149,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++;
|
||||
|
Loading…
Reference in New Issue
Block a user