diff options
author | Chaehyun Lim | 2015-09-17 09:48:45 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-09-19 04:46:41 +0200 |
commit | a0e5facedb4a1c7892a6f6f7a749eaf9b23fbbe1 (patch) | |
tree | dd9e0f2877b174c58f1970793f33396a0945eb9a | |
parent | staging: wilc1000: replace __inline with inline (diff) | |
download | kernel-qcow2-linux-a0e5facedb4a1c7892a6f6f7a749eaf9b23fbbe1.tar.gz kernel-qcow2-linux-a0e5facedb4a1c7892a6f6f7a749eaf9b23fbbe1.tar.xz kernel-qcow2-linux-a0e5facedb4a1c7892a6f6f7a749eaf9b23fbbe1.zip |
staging: wilc1000: linux_wlan_spi.c: fix kzalloc error check
This patch fixes error check of kzalloc.
If kzalloc is failed, return type is used as -ENOMEM.
Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/wilc1000/linux_wlan_spi.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index 3e2425647018..51bbd969e96b 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -125,10 +125,8 @@ int linux_spi_write(u8 *b, u32 len) int remainder = len % TXRX_PHASE_SIZE; char *r_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); - - if (!r_buffer) { - PRINT_ER("Failed to allocate memory for r_buffer\n"); - } + if (!r_buffer) + return -ENOMEM; if (blk) { while (i < blk) { @@ -208,10 +206,9 @@ int linux_spi_write(u8 *b, u32 len) .delay_usecs = 0, }; char *r_buffer = kzalloc(len, GFP_KERNEL); + if (!r_buffer) + return -ENOMEM; - if (!r_buffer) { - PRINT_ER("Failed to allocate memory for r_buffer\n"); - } tr.rx_buf = r_buffer; PRINT_D(BUS_DBG, "Request writing %d bytes\n", len); @@ -257,10 +254,8 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) int remainder = rlen % TXRX_PHASE_SIZE; char *t_buffer = kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL); - - if (!t_buffer) { - PRINT_ER("Failed to allocate memory for t_buffer\n"); - } + if (!t_buffer) + return -ENOMEM; if (blk) { while (i < blk) { @@ -337,10 +332,9 @@ int linux_spi_read(unsigned char *rb, unsigned long rlen) }; char *t_buffer = kzalloc(rlen, GFP_KERNEL); + if (!t_buffer) + return -ENOMEM; - if (!t_buffer) { - PRINT_ER("Failed to allocate memory for t_buffer\n"); - } tr.tx_buf = t_buffer; memset(&msg, 0, sizeof(msg)); |