diff options
author | thomas <thomas@FreeBSD.org> | 2003-10-08 07:12:30 +0000 |
---|---|---|
committer | thomas <thomas@FreeBSD.org> | 2003-10-08 07:12:30 +0000 |
commit | 9a1f9ceacc3a89c938f7bb7aa413646e54e24864 (patch) | |
tree | c95616ba831ed9ac93a85599f44d6456e666606d /sys/cam | |
parent | 352d9382c041c011790127badd240a6595f12fa7 (diff) | |
download | FreeBSD-src-9a1f9ceacc3a89c938f7bb7aa413646e54e24864.zip FreeBSD-src-9a1f9ceacc3a89c938f7bb7aa413646e54e24864.tar.gz |
(dacleanup, dasysctlinit): Defend against calling sysctl_ctx_free on
an uninitialized sysctl_ctx, using flag DA_FLAG_SCTX_INIT. This
prevents a panic encoutered with some umass units that probe correctly
but fail to attach. Same problem, and same fix, as scsi_cd.c rev. 1.86.
Reviewed by: njl, ken
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 20afef9..884e948 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -89,7 +89,8 @@ typedef enum { DA_FLAG_NEED_OTAG = 0x020, DA_FLAG_WENT_IDLE = 0x040, DA_FLAG_RETRY_UA = 0x080, - DA_FLAG_OPEN = 0x100 + DA_FLAG_OPEN = 0x100, + DA_FLAG_SCTX_INIT = 0x200 } da_flags; typedef enum { @@ -838,7 +839,8 @@ dacleanup(struct cam_periph *periph) /* * If we can't free the sysctl tree, oh well... */ - if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) { + if ((softc->flags & DA_FLAG_SCTX_INIT) != 0 + && sysctl_ctx_free(&softc->sysctl_ctx) != 0) { xpt_print_path(periph->path); printf("can't remove sysctl context\n"); } @@ -925,6 +927,7 @@ dasysctlinit(void *context, int pending) mtx_lock(&Giant); sysctl_ctx_init(&softc->sysctl_ctx); + softc->flags |= DA_FLAG_SCTX_INIT; softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_kern_cam_da), OID_AUTO, tmpstr2, CTLFLAG_RD, 0, tmpstr); |