(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
This commit is contained in:
thomas 2003-10-08 07:12:30 +00:00
parent 6d6f15daf5
commit f712071511

View File

@ -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);