spi: modified to the rx and tx buffers are not allocated when buffer size is zero. 87/154487/4
authorSegwon <segwon.han@samsung.com>
Tue, 10 Oct 2017 09:15:13 +0000 (18:15 +0900)
committerSegwon Han <segwon.han@samsung.com>
Tue, 10 Oct 2017 12:15:13 +0000 (12:15 +0000)
Change-Id: Ibaca59a040935701078140ca04eeef5dc3fb5280
Signed-off-by: Segwon <segwon.han@samsung.com>
src/daemon/peripheral_bus_spi.c

index 903b488..b690aa4 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: