1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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
This commit is contained in:
Kenneth D. Merry 2003-03-26 04:38:39 +00:00
parent 15d8f3d447
commit 461dddba27
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112668
2 changed files with 14 additions and 0 deletions

View File

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

View File

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