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 http://openocd.zylin.com/4418

-- gerrit

commit 2f8980eb171afdafd93d846f02e73a34abf9bc1e
Author: Tomas Vanek <van...@fbl.cz>
Date:   Fri Feb 16 09:13:36 2018 +0100

    drivers/ftdi: free allocated memory
    
    Also uses calloc() for mpsse_ctx->write_buffer to prevent a false
    positive valgrind report
    "Syscall param ioctl(USBDEVFS_SUBMITURB).buffer points to uninitialised 
bytes(s)"
    
    Change-Id: I91963371d15c21ea0fee4c40c1da86174db44520
    Signed-off-by: Tomas Vanek <van...@fbl.cz>

diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c
index e69707e..7c6709c 100644
--- a/src/jtag/drivers/ftdi.c
+++ b/src/jtag/drivers/ftdi.c
@@ -694,6 +694,18 @@ static int ftdi_quit(void)
 {
        mpsse_close(mpsse_ctx);
 
+       struct signal *sig = signals;
+       while (sig) {
+               struct signal *next = sig->next;
+               free((void *)sig->name);
+               free(sig);
+               sig = next;
+       }
+
+       free(ftdi_device_desc);
+       free(ftdi_serial);
+       free(ftdi_location);
+
        free(swd_cmd_queue);
 
        return ERROR_OK;
diff --git a/src/jtag/drivers/mpsse.c b/src/jtag/drivers/mpsse.c
index 924c974..74fed4e 100644
--- a/src/jtag/drivers/mpsse.c
+++ b/src/jtag/drivers/mpsse.c
@@ -335,7 +335,11 @@ struct mpsse_ctx *mpsse_open(const uint16_t *vid, const 
uint16_t *pid, const cha
        ctx->write_size = 16384;
        ctx->read_chunk = malloc(ctx->read_chunk_size);
        ctx->read_buffer = malloc(ctx->read_size);
-       ctx->write_buffer = malloc(ctx->write_size);
+       ctx->write_buffer = calloc(1, ctx->write_size);
+               /* Use calloc to make valgrind happy: buffer_write() sets 
payload
+                * on bit basis, so some bits can be left uninitialized in 
write_buffer.
+                * Although this is perfectly ok with MPSSE, valgrind reports
+                * Syscall param ioctl(USBDEVFS_SUBMITURB).buffer points to 
uninitialised byte(s) */
        if (!ctx->read_chunk || !ctx->read_buffer || !ctx->write_buffer)
                goto error;
 

-- 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to