2005-09-05 02:14:11

by Takis

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Panagiotis Issaris <[email protected]>
---

drivers/net/wireless/ipw2200.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

8e288419b49346fee512739acac446c951727d04
diff --git a/drivers/net/wireless/ipw2200.c
b/drivers/net/wireless/ipw2200.c
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queue
int 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);



2005-09-05 11:53:34

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH] ipw2200: Missing kmalloc check

Panagiotis Issaris napsal(a):

>The ipw2200 driver code in current GIT contains a kmalloc() followed by
>a memset() 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
>diff --git a/drivers/net/wireless/ipw2200.c
>b/drivers/net/wireless/ipw2200.c
>--- a/drivers/net/wireless/ipw2200.c
>+++ b/drivers/net/wireless/ipw2200.c
>@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queue
> int 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?

> spin_lock_init(&rxq->lock);
> INIT_LIST_HEAD(&rxq->rx_free);
>
>
--
Jiri Slaby http://www.fi.muni.cz/~xslaby
~\-/~ [email protected] ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10

2005-09-05 14:26:27

by Takis

[permalink] [raw]
Subject: Re: [PATCH] ipw2200: Missing kmalloc check

On 9/5/05, Jiri Slaby <[email protected]> wrote:
> > 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?

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

2005-11-07 18:32:28

by Rolf Eike Beer

[permalink] [raw]
Subject: Re: [PATCH] ipw2200: Missing kmalloc check

Panagiotis Issaris wrote:
>The ipw2200 driver code in current GIT contains a kmalloc() followed by
>a memset() 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
>diff --git a/drivers/net/wireless/ipw2200.c
>b/drivers/net/wireless/ipw2200.c
>--- a/drivers/net/wireless/ipw2200.c
>+++ b/drivers/net/wireless/ipw2200.c
>@@ -3976,6 +3976,10 @@ static struct ipw_rx_queue *ipw_rx_queue
> int 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


Attachments:
(No filename) (892.00 B)
(No filename) (189.00 B)
Download all attachments

2005-11-07 20:35:21

by Takis

[permalink] [raw]
Subject: Re: [PATCH] ipw2200: Missing kmalloc check

- Use kzalloc for IPW2200
- Fix config dependency for IPW2200

Signed-off-by: Panagiotis Issaris <[email protected]>

---

drivers/net/wireless/Kconfig | 2 +-
drivers/net/wireless/ipw2200.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)

applies-to: b3efbcb770e1202b65aee2fe70ea5a407a60e6a5
7e0cb9f1c4a239d06a0013997fc987c77fa46516
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 7187958..3cf1ae2 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -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
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 3db0c32..6da11b5 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -4029,12 +4029,11 @@ static struct ipw_rx_queue *ipw_rx_queue
struct 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