Skip to content

Commit

Permalink
ATM: solos-pci, remove use after free
Browse files Browse the repository at this point in the history
Stanse found we do in console_show:
  kfree_skb(skb);
  return skb->len;
which is not good. Fix that by remembering the len and use it in the
function instead.

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Chas Williams <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Slaby authored and davem330 committed Oct 11, 2010
1 parent 03c698c commit f1ee89d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/atm/solos-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,20 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr,
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
struct solos_card *card = atmdev->dev_data;
struct sk_buff *skb;
unsigned int len;

spin_lock(&card->cli_queue_lock);
skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]);
spin_unlock(&card->cli_queue_lock);
if(skb == NULL)
return sprintf(buf, "No data.\n");

memcpy(buf, skb->data, skb->len);
dev_dbg(&card->dev->dev, "len: %d\n", skb->len);
len = skb->len;
memcpy(buf, skb->data, len);
dev_dbg(&card->dev->dev, "len: %d\n", len);

kfree_skb(skb);
return skb->len;
return len;
}

static int send_command(struct solos_card *card, int dev, const char *buf, size_t size)
Expand Down

0 comments on commit f1ee89d

Please sign in to comment.