Commit f6194bcf authored by David B. Robins's avatar David B. Robins Committed by David S. Miller

net: usb: asix: Fix crash on skb alloc failure

If asix_rx_fixup_internal() fails to allocate rx->ax_skb, it will return
but not clear rx->size. rx points to driver private data. A later call
assumes that nonzero size means ax_skb was allocated and passes a null
ax_skb to skb_put. Changed allocation failure return to clear size first.

Found testing board with AX88772B devices.
Signed-off-by: default avatarDavid B. Robins <linux@davidrobins.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 74910ea4
...@@ -91,9 +91,11 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, ...@@ -91,9 +91,11 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
} }
rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, rx->ax_skb = netdev_alloc_skb_ip_align(dev->net,
rx->size); rx->size);
if (!rx->ax_skb) if (!rx->ax_skb) {
rx->size = 0;
return 0; return 0;
} }
}
if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) {
netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
......
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