accel/habanalabs/gaudi2: Fix incorrect string length computation in gaudi2_psoc_razwi...
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 4 Sep 2023 19:18:36 +0000 (21:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:59:11 +0000 (11:59 +0100)
commita5d2bb064cffbae71f7e0e5903b0970d33830b48
tree2a3d14f9490629e4323620b134748230318924fe
parent12d322fc6e658417ec5febc443c3889937baea99
accel/habanalabs/gaudi2: Fix incorrect string length computation in gaudi2_psoc_razwi_get_engines()

[ Upstream commit 90f3de616259cbb5666f00f8daf5420cd7d71d18 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/accel/habanalabs/gaudi2/gaudi2.c