summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi
diff options
context:
space:
mode:
authorken <ken@FreeBSD.org>2003-03-26 04:38:39 +0000
committerken <ken@FreeBSD.org>2003-03-26 04:38:39 +0000
commit70bd0898d60fb2ba96ed2a53c6793e4a26e1e9a6 (patch)
tree55fcde982310d70b959e99a3fccd476d3eacebc9 /sys/cam/scsi
parentb29b2ea5669747bf7af4f5a8a3dc82ec95dd802e (diff)
downloadFreeBSD-src-70bd0898d60fb2ba96ed2a53c6793e4a26e1e9a6.zip
FreeBSD-src-70bd0898d60fb2ba96ed2a53c6793e4a26e1e9a6.tar.gz
Clean up dynamically allocated sysctl variables when we run dacleanup() and
cdcleanup(). This fixes sysctl problems ("can't re-use a leaf") when someone adds another peripheral at the same unit number. (e.g. rescan da0, it goes away, then rescan again and da0 comes back, but since we haven't cleaned up the sysctl variables from the last da0 instance, we can't register the variables for the new instance under the same name.) Reported by: njl Tested by: njl
Diffstat (limited to 'sys/cam/scsi')
-rw-r--r--sys/cam/scsi/scsi_cd.c6
-rw-r--r--sys/cam/scsi/scsi_da.c8
2 files changed, 14 insertions, 0 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index bda6b7b..66b18f0 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -455,6 +455,11 @@ cdcleanup(struct cam_periph *periph)
xpt_print_path(periph->path);
printf("removing device entry\n");
+ if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
+ xpt_print_path(periph->path);
+ printf("can't remove sysctl context\n");
+ }
+
s = splsoftcam();
/*
* In the queued, non-active case, the device in question
@@ -688,6 +693,7 @@ cdregister(struct cam_periph *periph, void *arg)
snprintf(tmpstr, sizeof(tmpstr), "CAM CD unit %d", periph->unit_number);
snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
+ sysctl_ctx_init(&softc->sysctl_ctx);
softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_kern_cam_cd), OID_AUTO,
tmpstr2, CTLFLAG_RD, 0, tmpstr);
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 4007d29..bdb8276 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -987,6 +987,13 @@ dacleanup(struct cam_periph *periph)
xpt_print_path(periph->path);
printf("removing device entry\n");
+ /*
+ * If we can't free the sysctl tree, oh well...
+ */
+ if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
+ xpt_print_path(periph->path);
+ printf("can't remove sysctl context\n");
+ }
disk_destroy(&softc->disk);
free(softc, M_DEVBUF);
}
@@ -1142,6 +1149,7 @@ daregister(struct cam_periph *periph, void *arg)
snprintf(tmpstr, sizeof(tmpstr), "CAM DA unit %d", periph->unit_number);
snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number);
+ sysctl_ctx_init(&softc->sysctl_ctx);
softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx,
SYSCTL_STATIC_CHILDREN(_kern_cam_da), OID_AUTO, tmpstr2,
CTLFLAG_RD, 0, tmpstr);
OpenPOWER on IntegriCloud