Skip to content

Commit

Permalink
caif: Fix memory leakage in the chnl_net.c.
Browse files Browse the repository at this point in the history
Added kfree_skb() calls in the chnk_net.c file on
the error paths.

Signed-off-by: Sjur Brændeland <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Tomasz Gregorek authored and davem330 committed Apr 13, 2012
1 parent c9be48d commit 5c699fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/caif/chnl_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
skb->protocol = htons(ETH_P_IPV6);
break;
default:
kfree_skb(skb);
priv->netdev->stats.rx_errors++;
return -EINVAL;
}
Expand Down Expand Up @@ -220,14 +221,16 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)

if (skb->len > priv->netdev->mtu) {
pr_warn("Size of skb exceeded MTU\n");
kfree_skb(skb);
dev->stats.tx_errors++;
return -ENOSPC;
return NETDEV_TX_OK;
}

if (!priv->flowenabled) {
pr_debug("dropping packets flow off\n");
kfree_skb(skb);
dev->stats.tx_dropped++;
return NETDEV_TX_BUSY;
return NETDEV_TX_OK;
}

if (priv->conn_req.protocol == CAIFPROTO_DATAGRAM_LOOP)
Expand All @@ -242,7 +245,7 @@ static int chnl_net_start_xmit(struct sk_buff *skb, struct net_device *dev)
result = priv->chnl.dn->transmit(priv->chnl.dn, pkt);
if (result) {
dev->stats.tx_dropped++;
return result;
return NETDEV_TX_OK;
}

/* Update statistics. */
Expand Down

0 comments on commit 5c699fb

Please sign in to comment.