[SRU][Trusty][PATCH 1/1] net: cdc_ether: fix divide by 0 on bad descriptors

Kleber Sacilotto de Souza kleber.souza at canonical.com
Fri Oct 12 11:47:35 UTC 2018

From: Bjørn Mork <bjorn at mork.no>

Setting dev->hard_mtu to 0 will cause a divide error in
usbnet_probe. Protect against devices with bogus CDC Ethernet
functional descriptors by ignoring a zero wMaxSegmentSize.

Signed-off-by: Bjørn Mork <bjorn at mork.no>
Acked-by: Oliver Neukum <oneukum at suse.com>
Signed-off-by: David S. Miller <davem at davemloft.net>

(backported from commit 2cb80187ba065d7decad7c6614e35e07aec8a974)
[ kleber: parsing code is organised differently ]
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza at canonical.com>
 drivers/net/usb/cdc_ether.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index 2023f3ea891e..f0a924258035 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -237,8 +237,9 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
 				goto bad_desc;
-			dev->hard_mtu = le16_to_cpu(
-						info->ether->wMaxSegmentSize);
+			if (info->ether->wMaxSegmentSize)
+				dev->hard_mtu = le16_to_cpu(
+					info->ether->wMaxSegmentSize);
 			/* because of Zaurus, we may be ignoring the host
 			 * side link address we were given.

More information about the kernel-team mailing list