From 9a1f9ceacc3a89c938f7bb7aa413646e54e24864 Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 8 Oct 2003 07:12:30 +0000 Subject: (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 --- sys/cam/scsi/scsi_da.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sys/cam') 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); -- cgit v1.1