This is an automated email from Gerrit.

"Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/8733

-- gerrit

commit 00a4b901572a91033684d209a1d59672ebbb6ef3
Author: Tomas Vanek <van...@fbl.cz>
Date:   Mon Feb 3 20:28:49 2025 +0100

    drivers/linuxspidev: fix use of uninitialised 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 initialised. 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 <van...@fbl.cz>
    Fixes: 83e0293f7ba3 ("Add Linux SPI device SWD adapter support")

diff --git a/src/jtag/drivers/linuxspidev.c b/src/jtag/drivers/linuxspidev.c
index 94a0c510af..73d5e8bed4 100644
--- a/src/jtag/drivers/linuxspidev.c
+++ b/src/jtag/drivers/linuxspidev.c
@@ -307,18 +307,6 @@ static int spidev_init(void)
        LOG_INFO("Opened SPI device at %s in mode 0x%" PRIx32 " with %" PRIu8 " 
bits ",
                spi_path, spi_mode, spi_bits);
 
-       // Set SPI read and write max speed.
-       int speed;
-       ret = adapter_get_speed(&speed);
-       if (ret != ERROR_OK) {
-               LOG_ERROR("Failed to get adapter speed");
-               return ERROR_JTAG_INIT_FAILED;
-       }
-
-       ret = spidev_speed(speed);
-       if (ret != ERROR_OK)
-               return ERROR_JTAG_INIT_FAILED;
-
        if (max_queue_entries == 0) {
                ret = spidev_alloc_queue(MAX_QUEUE_ENTRIES);
                if (ret != ERROR_OK)

-- 

Reply via email to