Commit d5ba0bf6 authored by François Romieu's avatar François Romieu Committed by Linus Torvalds

[PATCH] 2.5.21 - hdlc drivers fixes

- (leak) memory allocated in dscc4_found1() isn't freed by caller in error path.
  dscc4_free1() is now in charge of this duty.
- (style) code factored in dscc4_remove_one after use of dscc4_free1().
parent ae2e9fea
...@@ -645,6 +645,24 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv, ...@@ -645,6 +645,24 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv,
rx_fd->end = 0xbabeface; rx_fd->end = 0xbabeface;
} }
static void dscc4_free1(struct pci_dev *pdev)
{
struct dscc4_pci_priv *ppriv;
struct dscc4_dev_priv *root;
int i;
ppriv = pci_get_drvdata(pdev);
root = ppriv->root;
for (i = 0; i < dev_per_card; i++)
unregister_hdlc_device(&root[i].hdlc);
pci_set_drvdata(pdev, NULL);
kfree(root);
kfree(ppriv);
}
static int __init dscc4_init_one(struct pci_dev *pdev, static int __init dscc4_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent) const struct pci_device_id *ent)
{ {
...@@ -693,7 +711,7 @@ static int __init dscc4_init_one(struct pci_dev *pdev, ...@@ -693,7 +711,7 @@ static int __init dscc4_init_one(struct pci_dev *pdev,
if (request_irq(pdev->irq, &dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root)){ if (request_irq(pdev->irq, &dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root)){
printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq); printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq);
goto err_out_iounmap; goto err_out_free1;
} }
/* power up/little endian/dma core controlled via lrda/ltda */ /* power up/little endian/dma core controlled via lrda/ltda */
...@@ -768,6 +786,8 @@ static int __init dscc4_init_one(struct pci_dev *pdev, ...@@ -768,6 +786,8 @@ static int __init dscc4_init_one(struct pci_dev *pdev,
priv->iqcfg_dma); priv->iqcfg_dma);
err_out_free_irq: err_out_free_irq:
free_irq(pdev->irq, priv->root); free_irq(pdev->irq, priv->root);
err_out_free1:
dscc4_free1(pdev);
err_out_iounmap: err_out_iounmap:
iounmap ((void *)ioaddr); iounmap ((void *)ioaddr);
err_out_free_mmio_region: err_out_free_mmio_region:
...@@ -1779,9 +1799,6 @@ static void __exit dscc4_remove_one(struct pci_dev *pdev) ...@@ -1779,9 +1799,6 @@ static void __exit dscc4_remove_one(struct pci_dev *pdev)
ppriv->iqcfg_dma); ppriv->iqcfg_dma);
for (i = 0; i < dev_per_card; i++) { for (i = 0; i < dev_per_card; i++) {
struct dscc4_dev_priv *dpriv = root + i; struct dscc4_dev_priv *dpriv = root + i;
hdlc_device *hdlc = &dpriv->hdlc;
unregister_hdlc_device(hdlc);
pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32), pci_free_consistent(pdev, IRQ_RING_SIZE*sizeof(u32),
dpriv->iqrx, dpriv->iqrx_dma); dpriv->iqrx, dpriv->iqrx_dma);
...@@ -1789,11 +1806,9 @@ static void __exit dscc4_remove_one(struct pci_dev *pdev) ...@@ -1789,11 +1806,9 @@ static void __exit dscc4_remove_one(struct pci_dev *pdev)
dpriv->iqtx, dpriv->iqtx_dma); dpriv->iqtx, dpriv->iqtx_dma);
} }
iounmap((void *)ioaddr); dscc4_free1(pdev);
kfree(root);
pci_set_drvdata(pdev, NULL); iounmap((void *)ioaddr);
kfree(ppriv);
release_mem_region(pci_resource_start(pdev, 1), release_mem_region(pci_resource_start(pdev, 1),
pci_resource_len(pdev, 1)); pci_resource_len(pdev, 1));
......
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