]> www.infradead.org Git - users/borneoa/openocd-next.git/commit
drivers/linuxspidev: fix use of uninitialized speed variable
authorTomas Vanek <vanekt@fbl.cz>
Mon, 3 Feb 2025 19:28:49 +0000 (20:28 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Tue, 11 Feb 2025 11:56:39 +0000 (11:56 +0000)
commit82277462b91506a9e7ee4bdcee86d6b414d59149
tree452eef49b53fa60ef23f6bc7a967d7e1f646704d
parent7dd875900ec252b5f332298cef3030f67a37150f
drivers/linuxspidev: fix use of uninitialized speed variable

Valgrind reported
== Syscall param ioctl(generic) points to uninitialised byte(s)
==    at 0x4ABF990: ioctl (ioctl.S:26)
==    by 0x19D00B: spidev_speed (linuxspidev.c:181)
==    by 0x19D00B: spidev_init (linuxspidev.c:307)

Indeed, spidev_init() uses adapter_get_speed(), it calls
adapter_khz_to_speed() and it returns early without setting
the output parameter if adapter is not initialized.
Of course the adapter initialized flag is not set until
spidev_init() returns.

Simply drop this code as the adapter infrastructure initializes
adapter speed just after spidev_init() return.

Change-Id: I26f011ae59fc942a34d9bb517f467c22f735091d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Fixes: 83e0293f7ba3 ("Add Linux SPI device SWD adapter support")
Reviewed-on: https://review.openocd.org/c/openocd/+/8733
Tested-by: jenkins
Reviewed-by: Richard Pasek <rpasek@google.com>
src/jtag/drivers/linuxspidev.c