diff options
Diffstat (limited to 'drivers/net/usb/usbnet.c')
-rw-r--r-- | drivers/net/usb/usbnet.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index d5071e364d40..453244805c52 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -384,8 +384,6 @@ int usbnet_change_mtu (struct net_device *net, int new_mtu) | |||
384 | int old_hard_mtu = dev->hard_mtu; | 384 | int old_hard_mtu = dev->hard_mtu; |
385 | int old_rx_urb_size = dev->rx_urb_size; | 385 | int old_rx_urb_size = dev->rx_urb_size; |
386 | 386 | ||
387 | if (new_mtu <= 0) | ||
388 | return -EINVAL; | ||
389 | // no second zero-length packet read wanted after mtu-sized packets | 387 | // no second zero-length packet read wanted after mtu-sized packets |
390 | if ((ll_mtu % dev->maxpacket) == 0) | 388 | if ((ll_mtu % dev->maxpacket) == 0) |
391 | return -EDOM; | 389 | return -EDOM; |
@@ -1669,6 +1667,8 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) | |||
1669 | * bind() should set rx_urb_size in that case. | 1667 | * bind() should set rx_urb_size in that case. |
1670 | */ | 1668 | */ |
1671 | dev->hard_mtu = net->mtu + net->hard_header_len; | 1669 | dev->hard_mtu = net->mtu + net->hard_header_len; |
1670 | net->min_mtu = 0; | ||
1671 | net->max_mtu = ETH_MAX_MTU; | ||
1672 | 1672 | ||
1673 | net->netdev_ops = &usbnet_netdev_ops; | 1673 | net->netdev_ops = &usbnet_netdev_ops; |
1674 | net->watchdog_timeo = TX_TIMEOUT_JIFFIES; | 1674 | net->watchdog_timeo = TX_TIMEOUT_JIFFIES; |
@@ -1929,7 +1929,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1929 | " value=0x%04x index=0x%04x size=%d\n", | 1929 | " value=0x%04x index=0x%04x size=%d\n", |
1930 | cmd, reqtype, value, index, size); | 1930 | cmd, reqtype, value, index, size); |
1931 | 1931 | ||
1932 | if (data) { | 1932 | if (size) { |
1933 | buf = kmalloc(size, GFP_KERNEL); | 1933 | buf = kmalloc(size, GFP_KERNEL); |
1934 | if (!buf) | 1934 | if (!buf) |
1935 | goto out; | 1935 | goto out; |
@@ -1938,8 +1938,13 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), | 1938 | err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), |
1939 | cmd, reqtype, value, index, buf, size, | 1939 | cmd, reqtype, value, index, buf, size, |
1940 | USB_CTRL_GET_TIMEOUT); | 1940 | USB_CTRL_GET_TIMEOUT); |
1941 | if (err > 0 && err <= size) | 1941 | if (err > 0 && err <= size) { |
1942 | memcpy(data, buf, err); | 1942 | if (data) |
1943 | memcpy(data, buf, err); | ||
1944 | else | ||
1945 | netdev_dbg(dev->net, | ||
1946 | "Huh? Data requested but thrown away.\n"); | ||
1947 | } | ||
1943 | kfree(buf); | 1948 | kfree(buf); |
1944 | out: | 1949 | out: |
1945 | return err; | 1950 | return err; |
@@ -1960,7 +1965,13 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, | |||
1960 | buf = kmemdup(data, size, GFP_KERNEL); | 1965 | buf = kmemdup(data, size, GFP_KERNEL); |
1961 | if (!buf) | 1966 | if (!buf) |
1962 | goto out; | 1967 | goto out; |
1963 | } | 1968 | } else { |
1969 | if (size) { | ||
1970 | WARN_ON_ONCE(1); | ||
1971 | err = -EINVAL; | ||
1972 | goto out; | ||
1973 | } | ||
1974 | } | ||
1964 | 1975 | ||
1965 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), | 1976 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), |
1966 | cmd, reqtype, value, index, buf, size, | 1977 | cmd, reqtype, value, index, buf, size, |