Commit 4bd6849a authored by Reinhard Speyerer's avatar Reinhard Speyerer Committed by Greg Kroah-Hartman

qmi_wwan: add support for QMAP padding in the RX path

[ Upstream commit 61356088 ]

The QMAP code in the qmi_wwan driver is based on the CodeAurora GobiNet
driver which does not process QMAP padding in the RX path correctly.
Add support for QMAP padding to qmimux_rx_fixup() according to the
description of the rmnet driver.

Fixes: c6adf779 ("net: usb: qmi_wwan: add qmap mux protocol support")
Cc: Daniele Palmas <dnlplm@gmail.com>
Signed-off-by: default avatarReinhard Speyerer <rspmn@arcor.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 86e69af6
...@@ -153,7 +153,7 @@ static bool qmimux_has_slaves(struct usbnet *dev) ...@@ -153,7 +153,7 @@ static bool qmimux_has_slaves(struct usbnet *dev)
static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb) static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
{ {
unsigned int len, offset = 0; unsigned int len, offset = 0, pad_len, pkt_len;
struct qmimux_hdr *hdr; struct qmimux_hdr *hdr;
struct net_device *net; struct net_device *net;
struct sk_buff *skbn; struct sk_buff *skbn;
...@@ -171,10 +171,16 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -171,10 +171,16 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
if (hdr->pad & 0x80) if (hdr->pad & 0x80)
goto skip; goto skip;
/* extract padding length and check for valid length info */
pad_len = hdr->pad & 0x3f;
if (len == 0 || pad_len >= len)
goto skip;
pkt_len = len - pad_len;
net = qmimux_find_dev(dev, hdr->mux_id); net = qmimux_find_dev(dev, hdr->mux_id);
if (!net) if (!net)
goto skip; goto skip;
skbn = netdev_alloc_skb(net, len); skbn = netdev_alloc_skb(net, pkt_len);
if (!skbn) if (!skbn)
return 0; return 0;
skbn->dev = net; skbn->dev = net;
...@@ -191,7 +197,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -191,7 +197,7 @@ static int qmimux_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
goto skip; goto skip;
} }
skb_put_data(skbn, skb->data + offset + qmimux_hdr_sz, len); skb_put_data(skbn, skb->data + offset + qmimux_hdr_sz, pkt_len);
if (netif_rx(skbn) != NET_RX_SUCCESS) if (netif_rx(skbn) != NET_RX_SUCCESS)
return 0; return 0;
......
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