lkml.org 
[lkml]   [2018]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] xen-pciback: Fix error return in bar_write() and rom_write()
Date
From: Dwayne Litzenberger <dlitz@dlitz.net>

Signed-off-by: Dwayne Litzenberger <dlitz@dlitz.net>
---
drivers/xen/xen-pciback/conf_space_header.c | 24 ++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/xen/xen-pciback/conf_space_header.c b/drivers/xen/xen-pciback/conf_space_header.c
index 10ae24b..697d0a8 100644
--- a/drivers/xen/xen-pciback/conf_space_header.c
+++ b/drivers/xen/xen-pciback/conf_space_header.c
@@ -135,6 +135,7 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)

static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
{
+ int err = 0;
struct pci_bar_info *bar = data;

if (unlikely(!bar)) {
@@ -150,17 +151,22 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
bar->which = 1;
else {
u32 tmpval;
- pci_read_config_dword(dev, offset, &tmpval);
+ err = pci_read_config_dword(dev, offset, &tmpval);
+ if (err)
+ goto out;
if (tmpval != bar->val && value == bar->val) {
/* Allow restoration of bar value. */
- pci_write_config_dword(dev, offset, bar->val);
+ err = pci_write_config_dword(dev, offset, bar->val);
+ if (err)
+ goto out;
}
bar->which = 0;
}

/* Do we need to support enabling/disabling the rom address here? */

- return 0;
+out:
+ return err;
}

/* For the BARs, only allow writes which write ~0 or
@@ -169,6 +175,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
*/
static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
{
+ int err = 0;
struct pci_bar_info *bar = data;
unsigned int pos = (offset - PCI_BASE_ADDRESS_0) / 4;
const struct resource *res = dev->resource;
@@ -193,15 +200,20 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
bar->which = 1;
else {
u32 tmpval;
- pci_read_config_dword(dev, offset, &tmpval);
+ err = pci_read_config_dword(dev, offset, &tmpval);
+ if (err)
+ goto out;
if (tmpval != bar->val && value == bar->val) {
/* Allow restoration of bar value. */
- pci_write_config_dword(dev, offset, bar->val);
+ err = pci_write_config_dword(dev, offset, bar->val);
+ if (err)
+ goto out;
}
bar->which = 0;
}

- return 0;
+out:
+ return err;
}

static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
--
git-series 0.9.1
\
 
 \ /
  Last update: 2018-12-02 18:50    [W:0.068 / U:0.832 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site