ipw2200: Missing kmalloc check
PATCH 1/1 ipw2200: Missing kmalloc check
The ipw2200 driver code in current GIT contains a kmalloc() followed by a memset() without handling a possible memory allocation failure.
---
drivers/net/wireless/ipw2200.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
8e288419b49346fee512739acac446c951727d04
(quoted diff) +0 -0
b/drivers/net/wireless/ipw2200.c
drivers/net/wireless/ipw2200.c +4 -0
@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queueint i; rxq = (struct ipw_rx_queue *)kmalloc (sizeof (*rxq),GFP_KERNEL ); +if (unlikely (!rxq)) { +IPW_ERROR ("memory allocation failed\n" ); +return NULL ; + }memset (rxq,0 ,sizeof (*rxq));spin_lock_init (&rxq->lock);INIT_LIST_HEAD (&rxq->rx_free);
Panagiotis Issaris napsal(a):
Quoted 15 lines
The ipw2200 driver code in current GIT contains a
kmalloc()followed by amemset()without handling a possible memory allocation failure.Signed-off-by Panagiotis Issaris <[email protected]>---
drivers/net/wireless/ipw2200.c| 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)
8e288419b49346fee512739acac446c951727d04
drivers/net/wireless/ipw2200.c static struct ipw_rx_queue *ipw_rx_queue · line 3985
Quoted 10 lines
drivers/net/wireless/ipw2200.c +4
-0@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queueint i; rxq = (struct ipw_rx_queue *)kmalloc (sizeof (*rxq),GFP_KERNEL ); +if (unlikely (!rxq)) { +IPW_ERROR ("memory allocation failed\n" ); +return NULL ; + }memset (rxq,0 ,sizeof (*rxq));
and use kzalloc instead of kmalloc and memset 0?
Quoted 4 lines
spin_lock_init(&rxq->lock); INIT_LIST_HEAD(&rxq->rx_free);
Signature · 3 lines
Jiri Slaby www.fi.muni.cz/~xslaby ~\-/~ [email protected] ~\-/~ 241B347EC88228DE51EE A49C4A73A25004CB2A10
Quoted 9 lines · Jiri Slaby
drivers/net/wireless/ipw2200.c static struct ipw_rx_queue *ipw_rx_queue · line 3983
Quoted 8 lines
rxq = (struct ipw_rx_queue *)kmalloc(sizeof(*rxq), GFP_KERNEL);drivers/net/wireless/ipw2200.c +4
-0+if (unlikely (!rxq)) { +IPW_ERROR ("memory allocation failed\n" ); +return NULL ; + }memset (rxq,0 ,sizeof (*rxq));and use kzalloc instead of kmalloc and memset 0?
Yes, but Morton's tree hasn't got the ipw2200 yet, while Linus' Linux-tree hasn't pulled in the patches containing kzalloc. I'll send a new patch as soon as the kzalloc patch get in Linus' tree or ipw in Marton's.
With friendly regards,
Takis
Jeff Garzik
Appliedapplied
Quoted 15 lines · Panagiotis Issaris
The ipw2200 driver code in current GIT contains a
kmalloc()followed by amemset()without handling a possible memory allocation failure.Signed-off-by Panagiotis Issaris <[email protected]>---
drivers/net/wireless/ipw2200.c| 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)
8e288419b49346fee512739acac446c951727d04
drivers/net/wireless/ipw2200.c static struct ipw_rx_queue *ipw_rx_queue · line 3983
Quoted 8 lines
drivers/net/wireless/ipw2200.c +4
-0@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queueint i; rxq = (struct ipw_rx_queue *)kmalloc (sizeof (*rxq),GFP_KERNEL ); +if (unlikely (!rxq)) { +IPW_ERROR ("memory allocation failed\n" ); +return NULL ; + }memset (rxq,0 ,sizeof (*rxq));
Please remove the cast and use kzalloc() instead of kmalloc() and memset(,0,).
Eike
- Use kzalloc for IPW2200
- Fix config dependency for IPW2200
---
drivers/net/wireless/Kconfig | 2 +- drivers/net/wireless/ipw2200.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-)
applies-to: b3efbcb770e1202b65aee2fe70ea5a407a60e6a5 7e0cb9f1c4a239d06a0013997fc987c77fa46516
drivers/net/wireless/Kconfig +1 -1
@@ -192,7 +192,7 @@ config IPW_DEBUG config IPW2200 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" - depends on IEEE80211 && PCI + depends on NET_RADIO && IEEE80211 && PCI select FW_LOADER ---help--- A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network
drivers/net/wireless/ipw2200.c +1 -2
@@ -4029,12 +4029,11 @@ static struct ipw_rx_queue *ipw_rx_queuestruct ipw_rx_queue *rxq;int i; - rxq = (struct ipw_rx_queue *)kmalloc (sizeof (*rxq),GFP_KERNEL ); + rxq =kzalloc (sizeof (*rxq),GFP_KERNEL );if (unlikely (!rxq)) {IPW_ERROR ("memory allocation failed\n" );return NULL ; } -memset (rxq,0 ,sizeof (*rxq));spin_lock_init (&rxq->lock);INIT_LIST_HEAD (&rxq->rx_free);INIT_LIST_HEAD (&rxq->rx_used);
---
0.99.9.GIT