aboutsummaryrefslogtreecommitdiff
path: root/drivers/ntb/ntb_hw.c
diff options
context:
space:
mode:
authorJon Mason <jon.mason@intel.com>2013-07-15 13:23:47 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-13 12:05:34 +0900
commit21720562911f038d7406654e7ea0c171cfac47b8 (patch)
tree74b97d9062d54027ab47830d3f49d5ca30a9b4a6 /drivers/ntb/ntb_hw.c
parentdad483b78d280665a110591fd418535e0f9791dc (diff)
NTB: Add Error Handling in ntb_device_setup
commit 3b12a0d15bd1559e72ad21d9d807fd2a6706f0ab upstream. If an error is encountered in ntb_device_setup, it is possible that the spci_cmd isn't populated. Writes to the offset can result in a NULL pointer dereference. This issue is easily encountered by running in NTB-RP mode, as it currently is not supported and will generate an error. To get around this issue, return if an error is encountered prior to attempting to write to the spci_cmd offset. Signed-off-by: Jon Mason <jon.mason@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/ntb/ntb_hw.c')
-rw-r--r--drivers/ntb/ntb_hw.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/ntb/ntb_hw.c b/drivers/ntb/ntb_hw.c
index 2dacd19e1b8..515099ee12f 100644
--- a/drivers/ntb/ntb_hw.c
+++ b/drivers/ntb/ntb_hw.c
@@ -644,10 +644,13 @@ static int ntb_device_setup(struct ntb_device *ndev)
rc = -ENODEV;
}
+ if (rc)
+ return rc;
+
/* Enable Bus Master and Memory Space on the secondary side */
writew(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER, ndev->reg_ofs.spci_cmd);
- return rc;
+ return 0;
}
static void ntb_device_free(struct ntb_device *ndev)