Skip to contentSkip to conversation

Staging: rtl8188eu fix buffer overflow

PATCH In review Matteo Semenzato 2 participants 2 messages Mar 20, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8188eu fix buffer overflow

From: Matteo Semenzato <[email protected]>

This patch fixes the buffer overflow caused by accessing index 4 of hwxmits.

---
 drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8188eu/core/rtw_xmit.c +3 -1
index 7a71df1..7b22779 100644
@@ -1631,10 +1631,12 @@ void rtw_alloc_hwxmits(struct adapter *padapter)
 {
 	struct hw_xmit *hwxmits;
 	struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
+	size_t size;
 
 	pxmitpriv->hwxmit_entry = HWXMIT_ENTRY;
 
-	pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL);
+	size =  sizeof(struct hw_xmit) * (pxmitpriv->hwxmit_entry + 1);
+	pxmitpriv->hwxmits = kzalloc(size, GFP_KERNEL);
 
 	hwxmits = pxmitpriv->hwxmits;
 
Signature · 1 line
2.3.2
#1 lore raw
Quoted 4 lines · Matteo Semenzato

From: Matteo Semenzato <[email protected]>

This patch fixes the buffer overflow caused by accessing index 4 of hwxmits.

This is a Smatch warning? It's a false positive because the code that accesses hwxmits[4] is dead code. Just delete it that section.

regards,
dan carpenter