ata: sata_mv: Fix incorrect string length computation in mv_dump_mem()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 4 Sep 2023 19:54:36 +0000 (21:54 +0200)
committerDamien Le Moal <dlemoal@kernel.org>
Mon, 11 Sep 2023 06:13:35 +0000 (15:13 +0900)
commite97eb65dd464e7f118a16a26337322d07eb653e2
tree59f4d07c48e20c1ffadff7865588a6a868bb06fd
parent24e0e61db3cb86a66824531989f1df80e0939f26
ata: sata_mv: Fix incorrect string length computation in mv_dump_mem()

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 'o' (and potential negative values
for "sizeof(linebuf) o") use scnprintf() instead of snprintf().

Note that given the "w < 4" in the for loop, the buffer can NOT
overflow, but using the *right* function is always better.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
drivers/ata/sata_mv.c