Commit 918b7024 authored by David S. Miller's avatar David S. Miller

Merge branch 'skb_cow_head'

Eric Dumazet says:

====================
net: use skb_cow_head() to deal with cloned skbs

James Hughes found an issue with smsc95xx driver. Same problematic code
is found in other drivers.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 95b9b88d 39fba783
...@@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ...@@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
tx_overhead = 0x40; tx_overhead = 0x40;
len = skb->len; len = skb->len;
if (skb_headroom(skb) < tx_overhead) { if (skb_cow_head(skb, tx_overhead)) {
struct sk_buff *skb2;
skb2 = skb_copy_expand(skb, tx_overhead, 0, flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = skb2; return NULL;
if (!skb)
return NULL;
} }
__skb_push(skb, tx_overhead); __skb_push(skb, tx_overhead);
......
...@@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ...@@ -293,12 +293,9 @@ static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
{ {
int len = skb->len; int len = skb->len;
if (skb_headroom(skb) < 2) { if (skb_cow_head(skb, 2)) {
struct sk_buff *skb2 = skb_copy_expand(skb, 2, 0, flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = skb2; return NULL;
if (!skb)
return NULL;
} }
skb_push(skb, 2); skb_push(skb, 2);
......
...@@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, ...@@ -803,18 +803,12 @@ static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb,
} }
/* We now decide whether we can put our special header into the sk_buff */ /* We now decide whether we can put our special header into the sk_buff */
if (skb_cloned(skb) || skb_headroom(skb) < 2) { if (skb_cow_head(skb, 2)) {
/* no such luck - we make our own */ kaweth->stats.tx_errors++;
struct sk_buff *copied_skb; netif_start_queue(net);
copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); spin_unlock_irq(&kaweth->device_lock);
dev_kfree_skb_irq(skb); dev_kfree_skb_any(skb);
skb = copied_skb; return NETDEV_TX_OK;
if (!copied_skb) {
kaweth->stats.tx_errors++;
netif_start_queue(net);
spin_unlock_irq(&kaweth->device_lock);
return NETDEV_TX_OK;
}
} }
private_header = (__le16 *)__skb_push(skb, 2); private_header = (__le16 *)__skb_push(skb, 2);
......
...@@ -2607,14 +2607,9 @@ static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev, ...@@ -2607,14 +2607,9 @@ static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev,
{ {
u32 tx_cmd_a, tx_cmd_b; u32 tx_cmd_a, tx_cmd_b;
if (skb_headroom(skb) < TX_OVERHEAD) { if (skb_cow_head(skb, TX_OVERHEAD)) {
struct sk_buff *skb2;
skb2 = skb_copy_expand(skb, TX_OVERHEAD, 0, flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = skb2; return NULL;
if (!skb)
return NULL;
} }
if (lan78xx_linearize(skb) < 0) if (lan78xx_linearize(skb) < 0)
......
...@@ -2203,13 +2203,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, ...@@ -2203,13 +2203,9 @@ static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev,
{ {
u32 tx_cmd_a, tx_cmd_b; u32 tx_cmd_a, tx_cmd_b;
if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { if (skb_cow_head(skb, SMSC75XX_TX_OVERHEAD)) {
struct sk_buff *skb2 =
skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = skb2; return NULL;
if (!skb)
return NULL;
} }
tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS;
......
...@@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ...@@ -456,14 +456,9 @@ static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
len = skb->len; len = skb->len;
if (skb_headroom(skb) < SR_TX_OVERHEAD) { if (skb_cow_head(skb, SR_TX_OVERHEAD)) {
struct sk_buff *skb2;
skb2 = skb_copy_expand(skb, SR_TX_OVERHEAD, 0, flags);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
skb = skb2; return NULL;
if (!skb)
return NULL;
} }
__skb_push(skb, SR_TX_OVERHEAD); __skb_push(skb, SR_TX_OVERHEAD);
......
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