Commit 65bc0aaa authored by David Matlack's avatar David Matlack Committed by Greg Kroah-Hartman

staging: slicoss: fix use-after-free in slic_entry_probe

This patch fixes a use-after-free bug that can cause a kernel
oops. If slic_card_init fails then slic_entry_probe (the pci
probe() function for this device) will return error without
cleaning up memory.
Signed-off-by: default avatarDavid Matlack <dmatlack@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8522851e
...@@ -3594,7 +3594,6 @@ static int slic_entry_probe(struct pci_dev *pcidev, ...@@ -3594,7 +3594,6 @@ static int slic_entry_probe(struct pci_dev *pcidev,
struct net_device *netdev; struct net_device *netdev;
struct adapter *adapter; struct adapter *adapter;
void __iomem *memmapped_ioaddr = NULL; void __iomem *memmapped_ioaddr = NULL;
u32 status = 0;
ulong mmio_start = 0; ulong mmio_start = 0;
ulong mmio_len = 0; ulong mmio_len = 0;
struct sliccard *card = NULL; struct sliccard *card = NULL;
...@@ -3685,16 +3684,11 @@ static int slic_entry_probe(struct pci_dev *pcidev, ...@@ -3685,16 +3684,11 @@ static int slic_entry_probe(struct pci_dev *pcidev,
adapter->allocated = 1; adapter->allocated = 1;
} }
status = slic_card_init(card, adapter); err = slic_card_init(card, adapter);
if (err)
goto err_out_unmap;
if (status != 0) { slic_adapter_set_hwaddr(adapter);
card->state = CARD_FAIL;
adapter->state = ADAPT_FAIL;
adapter->linkstate = LINK_DOWN;
dev_err(&pcidev->dev, "FAILED status[%x]\n", status);
} else {
slic_adapter_set_hwaddr(adapter);
}
netdev->base_addr = (unsigned long)adapter->memorybase; netdev->base_addr = (unsigned long)adapter->memorybase;
netdev->irq = adapter->irq; netdev->irq = adapter->irq;
...@@ -3711,7 +3705,7 @@ static int slic_entry_probe(struct pci_dev *pcidev, ...@@ -3711,7 +3705,7 @@ static int slic_entry_probe(struct pci_dev *pcidev,
cards_found++; cards_found++;
return status; return 0;
err_out_unmap: err_out_unmap:
iounmap(memmapped_ioaddr); iounmap(memmapped_ioaddr);
......
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