Commit d3ce65d1 authored by Tony Battersby's avatar Tony Battersby Committed by James Bottomley

[SCSI] sym53c8xx: fix shost use-after-free and memory leak

This patch fixes two bugs:

1) rmmod sym53c8xx uses shost after freeing it with
   scsi_put_host(shost).

2) insmod sym53c8xx doesn't call scsi_put_host(shost) if
   scsi_add_host() fails, causing a memory leak on the error path.
Signed-off-by: default avatarTony Battersby <tonyb@cybernetics.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
parent 2cf22be0
...@@ -1660,6 +1660,7 @@ static int sym_detach(struct Scsi_Host *shost, struct pci_dev *pdev) ...@@ -1660,6 +1660,7 @@ static int sym_detach(struct Scsi_Host *shost, struct pci_dev *pdev)
OUTB(np, nc_istat, 0); OUTB(np, nc_istat, 0);
sym_free_resources(np, pdev); sym_free_resources(np, pdev);
scsi_host_put(shost);
return 1; return 1;
} }
...@@ -1749,7 +1750,6 @@ static void sym2_remove(struct pci_dev *pdev) ...@@ -1749,7 +1750,6 @@ static void sym2_remove(struct pci_dev *pdev)
struct Scsi_Host *shost = pci_get_drvdata(pdev); struct Scsi_Host *shost = pci_get_drvdata(pdev);
scsi_remove_host(shost); scsi_remove_host(shost);
scsi_host_put(shost);
sym_detach(shost, pdev); sym_detach(shost, pdev);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
......
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