Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e8f26c2 authored by Anton Vasilyev's avatar Anton Vasilyev Committed by Greg Kroah-Hartman
Browse files

scsi: 3ware: fix return 0 on the error path of probe



[ Upstream commit 4dc98c1995482262e70e83ef029135247fafe0f2 ]

tw_probe() returns 0 in case of fail of tw_initialize_device_extension(),
pci_resource_start() or tw_reset_sequence() and releases resources.
twl_probe() returns 0 in case of fail of twl_initialize_device_extension(),
pci_iomap() and twl_reset_sequence().  twa_probe() returns 0 in case of
fail of tw_initialize_device_extension(), ioremap() and
twa_reset_sequence().

The patch adds retval initialization for these cases.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: default avatarAnton Vasilyev <vasilyev@ispras.ru>
Acked-by: default avatarAdam Radford <aradford@gmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9ab2733
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2057,6 +2057,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)

	if (twa_initialize_device_extension(tw_dev)) {
		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x25, "Failed to initialize device extension");
		retval = -ENOMEM;
		goto out_free_device_extension;
	}

@@ -2079,6 +2080,7 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
	tw_dev->base_addr = ioremap(mem_addr, mem_len);
	if (!tw_dev->base_addr) {
		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x35, "Failed to ioremap");
		retval = -ENOMEM;
		goto out_release_mem_region;
	}

@@ -2086,8 +2088,10 @@ static int twa_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
	TW_DISABLE_INTERRUPTS(tw_dev);

	/* Initialize the card */
	if (twa_reset_sequence(tw_dev, 0))
	if (twa_reset_sequence(tw_dev, 0)) {
		retval = -ENOMEM;
		goto out_iounmap;
	}

	/* Set host specific parameters */
	if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) ||
+3 −0
Original line number Diff line number Diff line
@@ -1613,6 +1613,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)

	if (twl_initialize_device_extension(tw_dev)) {
		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Failed to initialize device extension");
		retval = -ENOMEM;
		goto out_free_device_extension;
	}

@@ -1627,6 +1628,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
	tw_dev->base_addr = pci_iomap(pdev, 1, 0);
	if (!tw_dev->base_addr) {
		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1c, "Failed to ioremap");
		retval = -ENOMEM;
		goto out_release_mem_region;
	}

@@ -1636,6 +1638,7 @@ static int twl_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
	/* Initialize the card */
	if (twl_reset_sequence(tw_dev, 0)) {
		TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1d, "Controller reset failed during probe");
		retval = -ENOMEM;
		goto out_iounmap;
	}

+2 −0
Original line number Diff line number Diff line
@@ -2291,6 +2291,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)

	if (tw_initialize_device_extension(tw_dev)) {
		printk(KERN_WARNING "3w-xxxx: Failed to initialize device extension.");
		retval = -ENOMEM;
		goto out_free_device_extension;
	}

@@ -2305,6 +2306,7 @@ static int tw_probe(struct pci_dev *pdev, const struct pci_device_id *dev_id)
	tw_dev->base_addr = pci_resource_start(pdev, 0);
	if (!tw_dev->base_addr) {
		printk(KERN_WARNING "3w-xxxx: Failed to get io address.");
		retval = -ENOMEM;
		goto out_release_mem_region;
	}