From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergei Shtylyov Date: Thu, 29 Oct 2015 21:51:52 +0000 Subject: [PATCH 1/2] sh_eth: fix uninitialized arrays in sh_eth_ring_init() Message-Id: <6300720.GXPplNSh3O@wasted.cogentembedded.com> List-Id: References: <5844359.Wmo6777QiE@wasted.cogentembedded.com> In-Reply-To: <5844359.Wmo6777QiE@wasted.cogentembedded.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: netdev@vger.kernel.org Cc: linux-sh@vger.kernel.org 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 --- 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;