From: Hannes Reinecke <hare@suse.de>
To: "Maciej W. Rozycki" <macro@linux-mips.org>
Cc: netdev@vger.kernel.org, Michal Kubecek <mkubecek@suse.com>,
Hannes Reinecke <hare@suse.de>, Hannes Reinecke <hare@suse.com>
Subject: [PATCH] fddi: Fixup potential uninitialized bars
Date: Tue, 26 Jan 2016 08:27:31 +0100 [thread overview]
Message-ID: <1453793251-101247-1-git-send-email-hare@suse.de> (raw)
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@suse.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
next reply other threads:[~2016-01-26 7:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 7:27 Hannes Reinecke [this message]
2016-01-26 8:55 ` [PATCH] fddi: Fixup potential uninitialized bars Maciej W. Rozycki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453793251-101247-1-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=hare@suse.com \
--cc=macro@linux-mips.org \
--cc=mkubecek@suse.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).