提交 52d17851 编写于 作者: S stephen hemminger 提交者: David S. Miller

hdlc: fix null-deref on allocation failure

If alloc_netdev() failed and return NULL, then the next instruction
would dereference it. Found by Coverity.

Compile tested only. Not sure if anyone still uses this driver
(or the whole WAN subsystem).
Signed-off-by: NStephen Hemminger <stephen@networkplumber.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6f97532e
...@@ -1075,11 +1075,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) ...@@ -1075,11 +1075,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
used = pvc_is_used(pvc); used = pvc_is_used(pvc);
if (type == ARPHRD_ETHER) { if (type == ARPHRD_ETHER)
dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN, dev = alloc_netdev(0, "pvceth%d", NET_NAME_UNKNOWN,
ether_setup); ether_setup);
dev->priv_flags &= ~IFF_TX_SKB_SHARING; else
} else
dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup); dev = alloc_netdev(0, "pvc%d", NET_NAME_UNKNOWN, pvc_setup);
if (!dev) { if (!dev) {
...@@ -1088,9 +1087,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) ...@@ -1088,9 +1087,10 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
return -ENOBUFS; return -ENOBUFS;
} }
if (type == ARPHRD_ETHER) if (type == ARPHRD_ETHER) {
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
eth_hw_addr_random(dev); eth_hw_addr_random(dev);
else { } else {
*(__be16*)dev->dev_addr = htons(dlci); *(__be16*)dev->dev_addr = htons(dlci);
dlci_to_q922(dev->broadcast, dlci); dlci_to_q922(dev->broadcast, dlci);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册