spi: modified to the rx and tx buffers are not allocated when buffer size is zero. 49/154549/1
authorSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 09:15:13 +0000 (18:15 +0900)
committerSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 11:57:54 +0000 (20:57 +0900)
Change-Id: Iaf6de46674d3bcd57f9354c484dd5791458d937a
Signed-off-by: Segwon <segwon.han@samsung.com>
src/daemon/peripheral_bus_spi.c

index 903b48865e3fe4571808d1fd08e39540a085775d..b690aa47381232d8808b84f6fb0cd337a7ea4b65 100644 (file)
@@ -87,6 +87,10 @@ int peripheral_bus_spi_open(int bus, int cs, pb_data_h *handle, gpointer user_da
        spi_handle->dev.spi.cs = cs;
 
        if (!spi_get_buffer_size(&bufsiz)) {
+               if (bufsiz <= 0) {
+                       _E("Buffer size is less than or equal to zero");
+                       goto err_buf_size;
+               }
                if (initial_buffer_size > bufsiz) initial_buffer_size = bufsiz;
                if (max_buffer_size > bufsiz) max_buffer_size = bufsiz;
        }
@@ -116,6 +120,7 @@ err_tx_buf:
        spi_handle->dev.spi.rx_buf_size = 0;
 
 err_rx_buf:
+err_buf_size:
        peripheral_bus_data_free(spi_handle);
 
 err_spi_data: