lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1453793251-101247-1-git-send-email-hare@suse.de>
Date:	Tue, 26 Jan 2016 08:27:31 +0100
From:	Hannes Reinecke <hare@...e.de>
To:	"Maciej W. Rozycki" <macro@...ux-mips.org>
Cc:	netdev@...r.kernel.org, Michal Kubecek <mkubecek@...e.com>,
	Hannes Reinecke <hare@...e.de>, Hannes Reinecke <hare@...e.com>
Subject: [PATCH] fddi: Fixup potential uninitialized bars

dfx_get_bars() allocates the various bars, depending on the
bus type. But as the function itself returns void and there
is no default selection there is a risk of the function
returning without allocating any bars.
This patch moves the entries around so that PCI is assumed
to the the default bus, and adds a WARN_ON check if that
should no be the case.
And I've made some minor code reshuffles to keep checkpatch
happy.

Signed-off-by: Hannes Reinecke <hare@...e.com>
---
 drivers/net/fddi/defxx.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
index 7f975a2..5fcaf03 100644
--- a/drivers/net/fddi/defxx.c
+++ b/drivers/net/fddi/defxx.c
@@ -434,19 +434,10 @@ static void dfx_port_read_long(DFX_board_t *bp, int offset, u32 *data)
 static void dfx_get_bars(struct device *bdev,
 			 resource_size_t *bar_start, resource_size_t *bar_len)
 {
-	int dfx_bus_pci = dev_is_pci(bdev);
 	int dfx_bus_eisa = DFX_BUS_EISA(bdev);
 	int dfx_bus_tc = DFX_BUS_TC(bdev);
 	int dfx_use_mmio = DFX_MMIO || dfx_bus_tc;
 
-	if (dfx_bus_pci) {
-		int num = dfx_use_mmio ? 0 : 1;
-
-		bar_start[0] = pci_resource_start(to_pci_dev(bdev), num);
-		bar_len[0] = pci_resource_len(to_pci_dev(bdev), num);
-		bar_start[2] = bar_start[1] = 0;
-		bar_len[2] = bar_len[1] = 0;
-	}
 	if (dfx_bus_eisa) {
 		unsigned long base_addr = to_eisa_device(bdev)->base_addr;
 		resource_size_t bar_lo;
@@ -476,13 +467,25 @@ static void dfx_get_bars(struct device *bdev,
 		bar_len[1] = PI_ESIC_K_BURST_HOLDOFF_LEN;
 		bar_start[2] = base_addr + PI_ESIC_K_ESIC_CSR;
 		bar_len[2] = PI_ESIC_K_ESIC_CSR_LEN;
-	}
-	if (dfx_bus_tc) {
+	} else if (dfx_bus_tc) {
 		bar_start[0] = to_tc_dev(bdev)->resource.start +
 			       PI_TC_K_CSR_OFFSET;
 		bar_len[0] = PI_TC_K_CSR_LEN;
-		bar_start[2] = bar_start[1] = 0;
-		bar_len[2] = bar_len[1] = 0;
+		bar_start[1] = 0;
+		bar_len[1] = 0;
+		bar_start[2] = 0;
+		bar_len[2] = 0;
+	} else {
+		/* Assume PCI */
+		int num = dfx_use_mmio ? 0 : 1;
+
+		WARN_ON(!dev_is_pci(bdev));
+		bar_start[0] = pci_resource_start(to_pci_dev(bdev), num);
+		bar_len[0] = pci_resource_len(to_pci_dev(bdev), num);
+		bar_start[1] = 0;
+		bar_len[1] = 0;
+		bar_start[2] = 0;
+		bar_len[2] = 0;
 	}
 }
 
-- 
1.8.5.6

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ