sh_eth: fix uninitialized arrays in sh_eth_ring_init()
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Fri, 30 Oct 2015 23:05:56 +0000 (02:05 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Nov 2015 20:56:11 +0000 (15:56 -0500)
sh_eth_ring_free()  called in the sh_eth_ring_init()'s error path expects
the arrays pointed  to  by 'sh_eth_private::[rt]x_skbuff' to be initialized
with NULLs but they are allocated with just kmalloc_array() and so are left
filled with random data. Use kcalloc() instead.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/sh_eth.c

index a484d8beb8557935b30251dc70bf3ef3d3b64dbc..6e42851e97c854f2dc9b18f51a8da06e119a08dc 100644 (file)
@@ -1212,15 +1212,15 @@ static int sh_eth_ring_init(struct net_device *ndev)
                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;