i2c: fixed that allocated memory is released when an error occurs. 62/154562/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 12:21:51 +0000 (21:21 +0900)
Change-Id: Ib2c6589ad52b3752297bf6579527b574dba3b3d6
Signed-off-by: Segwon <segwon.han@samsung.com>
src/daemon/peripheral_bus_i2c.c

index 6c5ad4aeec51b69caa3dc099b3165d349b9cba71..b0a889982ebabf789746b5bd87a04929c936ca2a 100644 (file)
@@ -93,6 +93,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);
                _E("Failed to allocate data buffer");
                ret = PERIPHERAL_ERROR_OUT_OF_MEMORY;
                goto err;