Skip to contentSkip to conversation

Staging: Check kmalloc return value before use the buffer in ieee80211_softmac.c

PATCH In review [email protected] 2 participants 2 messages May 5, 2010 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: Check kmalloc return value before use the buffer in ieee80211_softmac.c

Check kmalloc return value before use the buffer.

---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +2 -0
index 27d9257..8718ac9 100644
@@ -1579,6 +1579,8 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
 		if(*(t++) == MFIE_TYPE_CHALLENGE){
 			*chlen = *(t++);
 			*challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
+			if (!*challenge)
+				return -ENOMEM;
 			memcpy(*challenge, t, *chlen);
 		}
 	}
Signature · 1 line
1.6.5.3
#1 lore raw
Quoted 13 lines · On Wed, May 05, 2010 at 02:56:52PM +0800, [email protected] wrote:

Check kmalloc return value before use the buffer.

---
 .../staging/rtl8192u/ieee80211/ieee80211_softmac.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +0 -0
index 27d9257..8718ac9 100644

drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) · line 1583

Quoted 5 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +2 -0
@@ -1579,6 +1579,8 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
 		if(*(t++) == MFIE_TYPE_CHALLENGE){
 			*chlen = *(t++);
 			*challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
+			if (!*challenge)
+				return -ENOMEM;

Great catch!

thanks for the patch, now queued up.

greg k-h