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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Oct 2023 12:56:53 +0000 (14:56 +0200)
commitdfbcef80dda96f6433eb6db6d146e68c46cf314c
tree2b414a918ed2e06583031be19a09948916aa86a0
parent797d75bd575cbc5263b870adad900ce0ae69cf06
ata: sata_mv: Fix incorrect string length computation in mv_dump_mem()

[ Upstream commit e97eb65dd464e7f118a16a26337322d07eb653e2 ]

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