Skip to content

Commit

Permalink
NTB: Add Error Handling in ntb_device_setup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jon Mason committed Sep 3, 2013
1 parent 6e46645 commit 3b12a0d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/ntb/ntb_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b12a0d

Please sign in to comment.