Commit c95aef41 authored by Vasiliy Kulikov's avatar Vasiliy Kulikov Committed by Greg Kroah-Hartman

staging: ft1000: fix skb, netdev, memory leaks

ft1000_copy_up_pkt() doesn't free skb on errors.
init_ft1000_card() doesn't free netdev with free_netdev() but with kfree().
init_ft1000_card() doesn't check request_region()'s return value
and doesn't free region on error.
Signed-off-by: default avatarVasiliy Kulikov <segooon@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 52cab756
...@@ -1686,6 +1686,7 @@ int ft1000_copy_up_pkt(struct net_device *dev) ...@@ -1686,6 +1686,7 @@ int ft1000_copy_up_pkt(struct net_device *dev)
tempword); tempword);
ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO); ft1000_flush_fifo(dev, DSP_PKTPHCKSUM_INFO);
info->stats.rx_errors++; info->stats.rx_errors++;
kfree_skb(skb);
return FAILURE; return FAILURE;
} }
//subtract the number of bytes read already //subtract the number of bytes read already
...@@ -1711,6 +1712,7 @@ int ft1000_copy_up_pkt(struct net_device *dev) ...@@ -1711,6 +1712,7 @@ int ft1000_copy_up_pkt(struct net_device *dev)
*pbuffer++ = (u8) (tempword >> 8); *pbuffer++ = (u8) (tempword >> 8);
*pbuffer++ = (u8) tempword; *pbuffer++ = (u8) tempword;
if (ft1000_chkcard(dev) == FALSE) { if (ft1000_chkcard(dev) == FALSE) {
kfree_skb(skb);
return FAILURE; return FAILURE;
} }
} }
...@@ -2236,15 +2238,17 @@ struct net_device *init_ft1000_card(unsigned short irq, int port, ...@@ -2236,15 +2238,17 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) { if (request_irq(dev->irq, ft1000_interrupt, IRQF_SHARED, dev->name, dev)) {
printk(KERN_ERR "ft1000: Could not request_irq\n"); printk(KERN_ERR "ft1000: Could not request_irq\n");
kfree(dev); goto err_dev;
return (NULL);
} }
request_region(dev->base_addr, 256, dev->name); if (request_region(dev->base_addr, 256, dev->name) == NULL) {
printk(KERN_ERR "ft1000: Could not request_region\n");
goto err_irq;
}
if (register_netdev(dev) != 0) { if (register_netdev(dev) != 0) {
DEBUG(0, "ft1000: Could not register netdev"); DEBUG(0, "ft1000: Could not register netdev");
return NULL; goto err_reg;
} }
info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID); info->AsicID = ft1000_read_reg(dev, FT1000_REG_ASIC_ID);
...@@ -2252,19 +2256,13 @@ struct net_device *init_ft1000_card(unsigned short irq, int port, ...@@ -2252,19 +2256,13 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n"); DEBUG(0, "ft1000_hw: ELECTRABUZZ ASIC\n");
if (request_firmware(&fw_entry, "ft1000.img", fdev) != 0) { if (request_firmware(&fw_entry, "ft1000.img", fdev) != 0) {
printk(KERN_INFO "ft1000: Could not open ft1000.img\n"); printk(KERN_INFO "ft1000: Could not open ft1000.img\n");
unregister_netdev(dev); goto err_unreg;
free_irq(dev->irq, dev);
kfree(dev);
return NULL;
} }
} else { } else {
DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n"); DEBUG(0, "ft1000_hw: MAGNEMITE ASIC\n");
if (request_firmware(&fw_entry, "ft2000.img", fdev) != 0) { if (request_firmware(&fw_entry, "ft2000.img", fdev) != 0) {
printk(KERN_INFO "ft1000: Could not open ft2000.img\n"); printk(KERN_INFO "ft1000: Could not open ft2000.img\n");
unregister_netdev(dev); goto err_unreg;
free_irq(dev->irq, dev);
kfree(dev);
return NULL;
} }
} }
...@@ -2279,6 +2277,16 @@ struct net_device *init_ft1000_card(unsigned short irq, int port, ...@@ -2279,6 +2277,16 @@ struct net_device *init_ft1000_card(unsigned short irq, int port,
dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[3],
dev->dev_addr[4], dev->dev_addr[5]); dev->dev_addr[4], dev->dev_addr[5]);
return dev; return dev;
err_unreg:
unregister_netdev(dev);
err_reg:
release_region(dev->base_addr, 256);
err_irq:
free_irq(dev->irq, dev);
err_dev:
free_netdev(dev);
return NULL;
} }
EXPORT_SYMBOL(init_ft1000_card); EXPORT_SYMBOL(init_ft1000_card);
......
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