netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] pxa168_eth: Allocate receive queue initialized to zero
@ 2013-06-18 17:30 Lubomir Rintel
  2013-06-20  5:19 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Lubomir Rintel @ 2013-06-18 17:30 UTC (permalink / raw)
  To: Kosta Zertsekel; +Cc: Lubomir Rintel, Kosta Zertsekel, netdev, linux-kernel

Zero pointer in rx_skb or tx_skb is how respective *_deinit() functions find
out that a skb slot is unallocated. If *_init() functions unsuccessfully return
after the allocation (e.g. when subsequent dma_alloc_coherent() is not
successful), this would result in attempt to kfree() invalid pointers.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Cc: Kosta Zertsekel <konszert@marvell.com>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
 drivers/net/ethernet/marvell/pxa168_eth.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 339bb32..1c8af8b 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1015,7 +1015,7 @@ static int rxq_init(struct net_device *dev)
 	int rx_desc_num = pep->rx_ring_size;
 
 	/* Allocate RX skb rings */
-	pep->rx_skb = kmalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size,
+	pep->rx_skb = kzalloc(sizeof(*pep->rx_skb) * pep->rx_ring_size,
 			     GFP_KERNEL);
 	if (!pep->rx_skb)
 		return -ENOMEM;
@@ -1076,7 +1076,7 @@ static int txq_init(struct net_device *dev)
 	int size = 0, i = 0;
 	int tx_desc_num = pep->tx_ring_size;
 
-	pep->tx_skb = kmalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size,
+	pep->tx_skb = kzalloc(sizeof(*pep->tx_skb) * pep->tx_ring_size,
 			     GFP_KERNEL);
 	if (!pep->tx_skb)
 		return -ENOMEM;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3] pxa168_eth: Allocate receive queue initialized to zero
  2013-06-18 17:30 [PATCH 1/3] pxa168_eth: Allocate receive queue initialized to zero Lubomir Rintel
@ 2013-06-20  5:19 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-06-20  5:19 UTC (permalink / raw)
  To: lkundrak; +Cc: konszert, netdev, linux-kernel

From: Lubomir Rintel <lkundrak@v3.sk>
Date: Tue, 18 Jun 2013 19:30:48 +0200

> Zero pointer in rx_skb or tx_skb is how respective *_deinit() functions find
> out that a skb slot is unallocated. If *_init() functions unsuccessfully return
> after the allocation (e.g. when subsequent dma_alloc_coherent() is not
> successful), this would result in attempt to kfree() invalid pointers.
> 
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-20  5:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-18 17:30 [PATCH 1/3] pxa168_eth: Allocate receive queue initialized to zero Lubomir Rintel
2013-06-20  5:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).