All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: netdev@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Subject: [PATCH 1/2] sh_eth: fix uninitialized arrays in sh_eth_ring_init()
Date: Thu, 29 Oct 2015 21:51:52 +0000	[thread overview]
Message-ID: <6300720.GXPplNSh3O@wasted.cogentembedded.com> (raw)
In-Reply-To: <5844359.Wmo6777QiE@wasted.cogentembedded.com>

sh_eth_ring_free()  called in the sh_eth_ring_init()'s error path  expects
the arrays pointed  by sh_eth_private::[rt]x_skbuff to be initialized with
NULLs  but they are allocated with just kmalloc_array() and so left filled
with random data. Use kcalloc() instead.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/net/ethernet/renesas/sh_eth.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: net/drivers/net/ethernet/renesas/sh_eth.c
=================================--- net.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net/drivers/net/ethernet/renesas/sh_eth.c
@@ -1212,15 +1212,15 @@ static int sh_eth_ring_init(struct net_d
 		mdp->rx_buf_sz += NET_IP_ALIGN;
 
 	/* Allocate RX and TX skb rings */
-	mdp->rx_skbuff = kmalloc_array(mdp->num_rx_ring,
-				       sizeof(*mdp->rx_skbuff), GFP_KERNEL);
+	mdp->rx_skbuff = kcalloc(mdp->num_rx_ring, sizeof(*mdp->rx_skbuff),
+				 GFP_KERNEL);
 	if (!mdp->rx_skbuff) {
 		ret = -ENOMEM;
 		return ret;
 	}
 
-	mdp->tx_skbuff = kmalloc_array(mdp->num_tx_ring,
-				       sizeof(*mdp->tx_skbuff), GFP_KERNEL);
+	mdp->tx_skbuff = kcalloc(mdp->num_tx_ring, sizeof(*mdp->tx_skbuff),
+				 GFP_KERNEL);
 	if (!mdp->tx_skbuff) {
 		ret = -ENOMEM;
 		goto skb_ring_free;


WARNING: multiple messages have this Message-ID (diff)
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: netdev@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Subject: [PATCH 1/2] sh_eth: fix uninitialized arrays in sh_eth_ring_init()
Date: Fri, 30 Oct 2015 00:51:52 +0300	[thread overview]
Message-ID: <6300720.GXPplNSh3O@wasted.cogentembedded.com> (raw)
In-Reply-To: <5844359.Wmo6777QiE@wasted.cogentembedded.com>

sh_eth_ring_free()  called in the sh_eth_ring_init()'s error path  expects
the arrays pointed  by sh_eth_private::[rt]x_skbuff to be initialized with
NULLs  but they are allocated with just kmalloc_array() and so left filled
with random data. Use kcalloc() instead.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/net/ethernet/renesas/sh_eth.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Index: net/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
--- net.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net/drivers/net/ethernet/renesas/sh_eth.c
@@ -1212,15 +1212,15 @@ static int sh_eth_ring_init(struct net_d
 		mdp->rx_buf_sz += NET_IP_ALIGN;
 
 	/* Allocate RX and TX skb rings */
-	mdp->rx_skbuff = kmalloc_array(mdp->num_rx_ring,
-				       sizeof(*mdp->rx_skbuff), GFP_KERNEL);
+	mdp->rx_skbuff = kcalloc(mdp->num_rx_ring, sizeof(*mdp->rx_skbuff),
+				 GFP_KERNEL);
 	if (!mdp->rx_skbuff) {
 		ret = -ENOMEM;
 		return ret;
 	}
 
-	mdp->tx_skbuff = kmalloc_array(mdp->num_tx_ring,
-				       sizeof(*mdp->tx_skbuff), GFP_KERNEL);
+	mdp->tx_skbuff = kcalloc(mdp->num_tx_ring, sizeof(*mdp->tx_skbuff),
+				 GFP_KERNEL);
 	if (!mdp->tx_skbuff) {
 		ret = -ENOMEM;
 		goto skb_ring_free;


  reply	other threads:[~2015-10-29 21:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 21:50 [PATCH 0/2] sh_eth: fix bugs in sh_eth_ring_init() Sergei Shtylyov
2015-10-29 21:50 ` Sergei Shtylyov
2015-10-29 21:51 ` Sergei Shtylyov [this message]
2015-10-29 21:51   ` [PATCH 1/2] sh_eth: fix uninitialized arrays " Sergei Shtylyov
2015-10-29 21:52 ` [PATCH 2/2] sh_eth: fix WARNING in dma_free_coherent() Sergei Shtylyov
2015-10-29 21:52   ` Sergei Shtylyov
2015-10-29 23:11   ` Sergei Shtylyov
2015-10-29 23:11     ` Sergei Shtylyov
2015-10-30 20:47     ` Sergei Shtylyov
2015-10-30 20:47       ` Sergei Shtylyov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6300720.GXPplNSh3O@wasted.cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=linux-sh@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.