Skip to content

Commit f1ee89d

Browse files
Jiri Slabydavem330
authored andcommitted
ATM: solos-pci, remove use after free
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 <jslaby@suse.cz> Cc: Chas Williams <chas@cmf.nrl.navy.mil> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 03c698c commit f1ee89d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎drivers/atm/solos-pci.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,20 @@ static ssize_t console_show(struct device *dev, struct device_attribute *attr,
444444
struct atm_dev *atmdev = container_of(dev, struct atm_dev, class_dev);
445445
struct solos_card *card = atmdev->dev_data;
446446
struct sk_buff *skb;
447+
unsigned int len;
447448

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

454-
memcpy(buf, skb->data, skb->len);
455-
dev_dbg(&card->dev->dev, "len: %d\n", skb->len);
455+
len = skb->len;
456+
memcpy(buf, skb->data, len);
457+
dev_dbg(&card->dev->dev, "len: %d\n", len);
456458

457459
kfree_skb(skb);
458-
return skb->len;
460+
return len;
459461
}
460462

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

0 commit comments

Comments
 (0)