i2c: fixed that allocated memory is released when an error occurs. 18/154518/1
authorSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 10:38:42 +0000 (19:38 +0900)
committerSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 10:38:42 +0000 (19:38 +0900)
Change-Id: Ib2c6589ad52b3752297bf6579527b574dba3b3d6
Signed-off-by: Segwon <segwon.han@samsung.com>
src/daemon/peripheral_bus_i2c.c

index f989022..d55bcef 100644 (file)
@@ -86,6 +86,7 @@ int peripheral_bus_i2c_open(int bus, int address, pb_data_h *handle, gpointer us
        i2c_handle->dev.i2c.buffer = malloc(INITIAL_BUFFER_SIZE);
 
        if (!(i2c_handle->dev.i2c.buffer)) {
+               peripheral_bus_data_free(i2c_handle);
                i2c_close(fd);
                _E("Failed to allocate data buffer");
                return PERIPHERAL_ERROR_OUT_OF_MEMORY;