Skip to content

Commit 1f4f554

Browse files
Dan Carpenterdavem330
authored andcommitted
net: qualcomm: rmnet: Fix a double free
There is a typo here so we accidentally free "skb" instead of "skbn". It leads to a double free and a leak. After discussing with Subash, it's better to just move the check before the allocation and avoid the need to free. Fixes: ceed73a ("drivers: net: ethernet: qualcomm: rmnet: Initial implementation") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Subash Abhinov Kasiviswanathan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad9a19d commit 1f4f554

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb)
8484
if (((int)skb->len - (int)packet_len) < 0)
8585
return NULL;
8686

87+
/* Some hardware can send us empty frames. Catch them */
88+
if (ntohs(maph->pkt_len) == 0)
89+
return NULL;
90+
8791
skbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, GFP_ATOMIC);
8892
if (!skbn)
8993
return NULL;
@@ -94,11 +98,5 @@ struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb)
9498
memcpy(skbn->data, skb->data, packet_len);
9599
skb_pull(skb, packet_len);
96100

97-
/* Some hardware can send us empty frames. Catch them */
98-
if (ntohs(maph->pkt_len) == 0) {
99-
kfree_skb(skb);
100-
return NULL;
101-
}
102-
103101
return skbn;
104102
}

0 commit comments

Comments
 (0)