summaryrefslogtreecommitdiffstats
path: root/sys/dev/dpt
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2004-01-17 05:57:52 +0000
committermdodd <mdodd@FreeBSD.org>2004-01-17 05:57:52 +0000
commit813cc04125bee8f7f0e6165a7d63287c4da2d13f (patch)
treefb48da59cf860ec5f9e0c9f2c37467c1e1cab8be /sys/dev/dpt
parent122cf1a39b961697ea0cbbe587da43a62aafcf45 (diff)
downloadFreeBSD-src-813cc04125bee8f7f0e6165a7d63287c4da2d13f.zip
FreeBSD-src-813cc04125bee8f7f0e6165a7d63287c4da2d13f.tar.gz
- Handle failure of cam_sim_alloc().
This prevents xpt_bus_register() from dereferencing NULL. - Assign pointer to NULL after cam_sim_free(). Submitted by: Paul Twohey <twohey@CS.Stanford.EDU>
Diffstat (limited to 'sys/dev/dpt')
-rw-r--r--sys/dev/dpt/dpt_scsi.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/dev/dpt/dpt_scsi.c b/sys/dev/dpt/dpt_scsi.c
index 0b2c726..4ae2cc8 100644
--- a/sys/dev/dpt/dpt_scsi.c
+++ b/sys/dev/dpt/dpt_scsi.c
@@ -1553,8 +1553,19 @@ dpt_attach(dpt_softc_t *dpt)
dpt->sims[i] = cam_sim_alloc(dpt_action, dpt_poll, "dpt",
dpt, dpt->unit, /*untagged*/2,
/*tagged*/dpt->max_dccbs, devq);
+ if (dpt->sims[i] == NULL) {
+ if (i == 0)
+ cam_simq_free(devq);
+ else
+ printf( "%s(): Unable to attach bus %d "
+ "due to resource shortage\n",
+ __func__, i);
+ break;
+ }
+
if (xpt_bus_register(dpt->sims[i], i) != CAM_SUCCESS) {
cam_sim_free(dpt->sims[i], /*free_devq*/i == 0);
+ dpt->sims[i] = NULL;
break;
}
@@ -1564,6 +1575,7 @@ dpt_attach(dpt_softc_t *dpt)
CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
xpt_bus_deregister(cam_sim_path(dpt->sims[i]));
cam_sim_free(dpt->sims[i], /*free_devq*/i == 0);
+ dpt->sims[i] = NULL;
break;
}
OpenPOWER on IntegriCloud