Commit 6a27224f authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Greg Kroah-Hartman

staging: wicl1000: fix dereference after free in wilc_wlan_cleanup()

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: c5c77ba1 ("staging: wilc1000: Add SDIO/SPI 802.11 driver")
Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dddaba1a
...@@ -1710,8 +1710,8 @@ static void wilc_wlan_cleanup(void) ...@@ -1710,8 +1710,8 @@ static void wilc_wlan_cleanup(void)
rqe = wilc_wlan_rxq_remove(); rqe = wilc_wlan_rxq_remove();
if (rqe == NULL) if (rqe == NULL)
break; break;
#ifdef MEMORY_DYNAMIC #ifndef MEMORY_STATIC
kfree(tqe->buffer); kfree(rqe->buffer);
#endif #endif
kfree(rqe); kfree(rqe);
} while (1); } while (1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment