Skip to content

Commit c34ca4f

Browse files
mchetankumardavem330
authored andcommitted
net: wwan: iosm: fix incorrect skb length
skb passed to network layer contains incorrect length. In mux aggregation protocol, the datagram block received from device contains block signature, packet & datagram header. The right skb len to be calculated by subracting datagram pad len from datagram length. Whereas in mux lite protocol, the skb contains single datagram so skb len is calculated by subtracting the packet offset from datagram header. Fixes: 1f52d7b ("net: wwan: iosm: Enable M.2 7360 WWAN card support") Signed-off-by: M Chetan Kumar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2290a1d commit c34ca4f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/net/wwan/iosm/iosm_ipc_mux_codec.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,16 @@ static void ipc_mux_dl_cmd_decode(struct iosm_mux *ipc_mux, struct sk_buff *skb)
365365
/* Pass the DL packet to the netif layer. */
366366
static int ipc_mux_net_receive(struct iosm_mux *ipc_mux, int if_id,
367367
struct iosm_wwan *wwan, u32 offset,
368-
u8 service_class, struct sk_buff *skb)
368+
u8 service_class, struct sk_buff *skb,
369+
u32 pkt_len)
369370
{
370371
struct sk_buff *dest_skb = skb_clone(skb, GFP_ATOMIC);
371372

372373
if (!dest_skb)
373374
return -ENOMEM;
374375

375376
skb_pull(dest_skb, offset);
376-
skb_set_tail_pointer(dest_skb, dest_skb->len);
377+
skb_trim(dest_skb, pkt_len);
377378
/* Pass the packet to the netif layer. */
378379
dest_skb->priority = service_class;
379380

@@ -429,7 +430,7 @@ static void ipc_mux_dl_fcth_decode(struct iosm_mux *ipc_mux,
429430
static void ipc_mux_dl_adgh_decode(struct iosm_mux *ipc_mux,
430431
struct sk_buff *skb)
431432
{
432-
u32 pad_len, packet_offset;
433+
u32 pad_len, packet_offset, adgh_len;
433434
struct iosm_wwan *wwan;
434435
struct mux_adgh *adgh;
435436
u8 *block = skb->data;
@@ -470,10 +471,12 @@ static void ipc_mux_dl_adgh_decode(struct iosm_mux *ipc_mux,
470471
packet_offset = sizeof(*adgh) + pad_len;
471472

472473
if_id += ipc_mux->wwan_q_offset;
474+
adgh_len = le16_to_cpu(adgh->length);
473475

474476
/* Pass the packet to the netif layer */
475477
rc = ipc_mux_net_receive(ipc_mux, if_id, wwan, packet_offset,
476-
adgh->service_class, skb);
478+
adgh->service_class, skb,
479+
adgh_len - packet_offset);
477480
if (rc) {
478481
dev_err(ipc_mux->dev, "mux adgh decoding error");
479482
return;
@@ -547,7 +550,7 @@ static int mux_dl_process_dg(struct iosm_mux *ipc_mux, struct mux_adbh *adbh,
547550
int if_id, int nr_of_dg)
548551
{
549552
u32 dl_head_pad_len = ipc_mux->session[if_id].dl_head_pad_len;
550-
u32 packet_offset, i, rc;
553+
u32 packet_offset, i, rc, dg_len;
551554

552555
for (i = 0; i < nr_of_dg; i++, dg++) {
553556
if (le32_to_cpu(dg->datagram_index)
@@ -562,11 +565,12 @@ static int mux_dl_process_dg(struct iosm_mux *ipc_mux, struct mux_adbh *adbh,
562565
packet_offset =
563566
le32_to_cpu(dg->datagram_index) +
564567
dl_head_pad_len;
568+
dg_len = le16_to_cpu(dg->datagram_length);
565569
/* Pass the packet to the netif layer. */
566570
rc = ipc_mux_net_receive(ipc_mux, if_id, ipc_mux->wwan,
567571
packet_offset,
568-
dg->service_class,
569-
skb);
572+
dg->service_class, skb,
573+
dg_len - dl_head_pad_len);
570574
if (rc)
571575
goto dg_error;
572576
}

0 commit comments

Comments
 (0)