Commit 2c94e856 authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by David S. Miller

sh_eth: fix uninitialized arrays in sh_eth_ring_init()

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: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 615a1003
...@@ -1212,15 +1212,15 @@ static int sh_eth_ring_init(struct net_device *ndev) ...@@ -1212,15 +1212,15 @@ static int sh_eth_ring_init(struct net_device *ndev)
mdp->rx_buf_sz += NET_IP_ALIGN; mdp->rx_buf_sz += NET_IP_ALIGN;
/* Allocate RX and TX skb rings */ /* Allocate RX and TX skb rings */
mdp->rx_skbuff = kmalloc_array(mdp->num_rx_ring, mdp->rx_skbuff = kcalloc(mdp->num_rx_ring, sizeof(*mdp->rx_skbuff),
sizeof(*mdp->rx_skbuff), GFP_KERNEL); GFP_KERNEL);
if (!mdp->rx_skbuff) { if (!mdp->rx_skbuff) {
ret = -ENOMEM; ret = -ENOMEM;
return ret; return ret;
} }
mdp->tx_skbuff = kmalloc_array(mdp->num_tx_ring, mdp->tx_skbuff = kcalloc(mdp->num_tx_ring, sizeof(*mdp->tx_skbuff),
sizeof(*mdp->tx_skbuff), GFP_KERNEL); GFP_KERNEL);
if (!mdp->tx_skbuff) { if (!mdp->tx_skbuff) {
ret = -ENOMEM; ret = -ENOMEM;
goto skb_ring_free; goto skb_ring_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment