aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Quinot <thomas@FreeBSD.org>2003-10-21 22:26:11 +0000
committerThomas Quinot <thomas@FreeBSD.org>2003-10-21 22:26:11 +0000
commita13293f19f7400c87ee08b43b4032405b13cb843 (patch)
tree8c4b6f4d0b97c9d0babe8467b07915a53f18965b
parentc35dd190545ce061a664b91f96e6ddae494f20d0 (diff)
downloadsrc-a13293f19f7400c87ee08b43b4032405b13cb843.tar.gz
src-a13293f19f7400c87ee08b43b4032405b13cb843.zip
MFC rev. 1.86:
(cdcleanup,cdsysctlinit): Defend against calling sysctl_ctx_free on an uninitialized sysctl_ctx. Approved by: re (murray)
Notes
Notes: svn path=/stable/4/; revision=121319
-rw-r--r--sys/cam/scsi/scsi_cd.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index 1da623ec6d93..628149ad2836 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -101,7 +101,8 @@ typedef enum {
CD_FLAG_RETRY_UA = 0x0200,
CD_FLAG_VALID_MEDIA = 0x0400,
CD_FLAG_VALID_TOC = 0x0800,
- CD_FLAG_OPEN = 0x1000
+ CD_FLAG_OPEN = 0x1000,
+ CD_FLAG_SCTX_INIT = 0x2000
} cd_flags;
typedef enum {
@@ -469,7 +470,9 @@ cdcleanup(struct cam_periph *periph)
xpt_print_path(periph->path);
printf("removing device entry\n");
- if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
+
+ if ((softc->flags & CD_FLAG_SCTX_INIT) != 0
+ && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
xpt_print_path(periph->path);
printf("can't remove sysctl context\n");
}
@@ -630,6 +633,7 @@ cdsysctlinit(void *context, int pending)
snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
sysctl_ctx_init(&softc->sysctl_ctx);
+ softc->flags |= CD_FLAG_SCTX_INIT;
softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_kern_cam_cd), OID_AUTO,
tmpstr2, CTLFLAG_RD, 0, tmpstr);