fix a double-free bug introduced by the following change. PR/38179.

revision 1.75
    date: 2008/01/29 17:26:57;  author: dyoung;  state: Exp;  lines: +34 -15
    Use device_t.  Add a handler for child detachment.  Now I can detach
    cd0 at atapibus0 without getting a panic when atapibus0 detaches,
    later.
This commit is contained in:
yamt 2008-03-08 10:31:52 +00:00
parent e769ba6b4a
commit ed28705cce

View File

@ -1,4 +1,4 @@
/* $NetBSD: atapiconf.c,v 1.75 2008/01/29 17:26:57 dyoung Exp $ */
/* $NetBSD: atapiconf.c,v 1.76 2008/03/08 10:31:52 yamt Exp $ */
/*
* Copyright (c) 1996, 2001 Manuel Bouyer. All rights reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.75 2008/01/29 17:26:57 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.76 2008/03/08 10:31:52 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -241,9 +241,7 @@ atapibusdetach(device_t self, int flags)
error = config_detach(periph->periph_dev, flags);
if (error)
return (error);
scsipi_remove_periph(chan, periph);
free(periph, M_DEVBUF);
KASSERT(scsipi_lookup_periph(chan, target, 0) == NULL);
}
return (0);
}