Fixed dangling pointer bugs in DIOCSDINFO.

Enabled DEVFS support.  It doesn't work while devfs is mounted
(add_devfs_devsw() doesn't work then), but seems to be safe.
This commit is contained in:
Bruce Evans 1996-01-28 08:15:44 +00:00
parent 60dc88f2ce
commit 80f9be1460
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13660

View File

@ -43,12 +43,11 @@
* from: wd.c,v 1.55 1994/10/22 01:57:12 phk Exp $
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
* from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $
* $Id: subr_diskslice.c,v 1.17 1996/01/16 18:11:24 phk Exp $
* $Id: subr_diskslice.c,v 1.18 1996/01/27 09:34:21 bde Exp $
*/
#include <sys/param.h>
#include <sys/buf.h>
#undef DEVFS /* XXX */
#ifdef DEVFS
#include <sys/devfsext.h>
#endif
@ -262,9 +261,6 @@ void
dsgone(sspp)
struct diskslices **sspp;
{
#ifdef DEVFS
int part;
#endif
int slice;
struct diskslice *sp;
struct diskslices *ssp;
@ -786,10 +782,14 @@ free_label(ssp, slice)
lp = sp->ds_label;
#ifdef DEVFS
for (part = 0; part < lp->d_npartitions; part++) {
if (sp->ds_bdevs[part] != NULL)
if (sp->ds_bdevs[part] != NULL) {
devfs_remove_dev(sp->ds_bdevs[part]);
if (sp->ds_cdevs[part] != NULL)
sp->ds_bdevs[part] = NULL;
}
if (sp->ds_cdevs[part] != NULL) {
devfs_remove_dev(sp->ds_cdevs[part]);
sp->ds_cdevs[part] = NULL;
}
}
#endif
free(lp, M_DEVBUF);