]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: wicl1000: fix dereference after free in wilc_wlan_cleanup()
authorJavier Martinez Canillas <javier@osg.samsung.com>
Tue, 22 Sep 2015 13:24:50 +0000 (15:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 00:31:19 +0000 (02:31 +0200)
The wilc_wlan_cleanup() function iterates over the list of transmission
buffers freeing all of them and then iterates over the receive buffers
list to free all of them as well.

But on the receive loop a pointer to struct txq_entry_t is dereferenced
instead of the pointer to a struct rxq_entry_t. This not only causes a
dereference to a pointer already freed but also leaks the memory in the
struct rxq_entry_t buffer.

Also, the buffer is allocated when MEMORY_STATIC is not defined no when
MEMORY_DYNAMIC is defined. So use #ifndef MEMORY_STATIC instead as it's
done in the rest of the driver to avoid leaking the buffer memory.

Fixes: c5c77ba18ea6 ("staging: wilc1000: Add SDIO/SPI 802.11 driver")
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_wlan.c

index 0a930ecef554a6b3f78617d30e591b20af84ced0..ddb03a82b0f9a966d9c1aa24c25a50db839d9b9c 100644 (file)
@@ -1710,8 +1710,8 @@ static void wilc_wlan_cleanup(void)
                rqe = wilc_wlan_rxq_remove();
                if (rqe == NULL)
                        break;
-#ifdef MEMORY_DYNAMIC
-               kfree(tqe->buffer);
+#ifndef MEMORY_STATIC
+               kfree(rqe->buffer);
 #endif
                kfree(rqe);
        } while (1);