linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: dc395x: fix null-ptr-dereference in adapter_uninit
@ 2021-03-21 17:59 Tong Zhang
  0 siblings, 0 replies; only message in thread
From: Tong Zhang @ 2021-03-21 17:59 UTC (permalink / raw)
  To: Oliver Neukum, Ali Akcaagac, Jamie Lenehan, James E.J. Bottomley,
	Martin K. Petersen, dc395x, linux-scsi, linux-kernel
  Cc: Tong Zhang

dcb_list is initialized in adapter_init_params(). When it is not
initialized, calling adapter_uninit() from dc395x_init_one() can cause
null-ptr-dereference. We can set acb to NULL and skip adapter_uninit()
alltogether if adapter_init() returns non zero, since adapter_init()
will handle its own unwinding without the help of adapter_uninit().

[    1.437872] BUG: kernel NULL pointer dereference, address: 0000000000000000
[    1.438251] #PF: supervisor read access in kernel mode
[    1.438529] #PF: error_code(0x0000) - not-present page
[    1.440130] RIP: 0010:adapter_uninit+0x94/0x170 [dc395x]
[    1.445439] Call Trace:
[    1.445573]  dc395x_init_one.cold+0x72a/0x9bb [dc395x]
[    1.445849]  local_pci_probe+0x48/0x80

Signed-off-by: Tong Zhang <ztong0001@gmail.com>
---
 drivers/scsi/dc395x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 3ea345c12467..990308cbf943 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -4647,6 +4647,7 @@ static int dc395x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 	/* initialise the adapter and everything we need */
  	if (adapter_init(acb, io_port_base, io_port_len, irq)) {
 		dprintkl(KERN_INFO, "adapter init failed\n");
+		acb = NULL;
 		goto fail;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-21 18:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-21 17:59 [PATCH] scsi: dc395x: fix null-ptr-dereference in adapter_uninit Tong Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).