Skip to content

Commit 69c867c

Browse files
sjur.brandeland@stericsson.comdavem330
authored andcommitted
caif: Plug memory leak for checksum error
In case of checksum error, the framing layer returns -EILSEQ, but does not free the packet. Plug this hole by freeing the packet if -EILSEQ is returned. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 138eded commit 69c867c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎net/caif/caif_dev.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int receive(struct sk_buff *skb, struct net_device *dev,
142142
{
143143
struct cfpkt *pkt;
144144
struct caif_device_entry *caifd;
145+
int err;
145146

146147
pkt = cfpkt_fromnative(CAIF_DIR_IN, skb);
147148

@@ -159,7 +160,11 @@ static int receive(struct sk_buff *skb, struct net_device *dev,
159160
caifd_hold(caifd);
160161
rcu_read_unlock();
161162

162-
caifd->layer.up->receive(caifd->layer.up, pkt);
163+
err = caifd->layer.up->receive(caifd->layer.up, pkt);
164+
165+
/* For -EILSEQ the packet is not freed so so it now */
166+
if (err == -EILSEQ)
167+
cfpkt_destroy(pkt);
163168

164169
/* Release reference to stack upwards */
165170
caifd_put(caifd);

0 commit comments

Comments
 (0)