In g_gate_dumpconf() always check the result of g_gate_hold().

This fixes "Negative sc_ref" panic possible when sysctl_kern_geom_confxml()
is run simultaneously with destroying GATE device.

Reviewed by:	pjd
MFC after:	3 days
This commit is contained in:
Mikolaj Golub 2012-08-07 18:50:33 +00:00
parent 6337d82014
commit 1d9db37c77

View File

@ -398,7 +398,9 @@ g_gate_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
sc = gp->softc;
if (sc == NULL || pp != NULL || cp != NULL)
return;
g_gate_hold(sc->sc_unit, NULL);
sc = g_gate_hold(sc->sc_unit, NULL);
if (sc == NULL)
return;
if ((sc->sc_flags & G_GATE_FLAG_READONLY) != 0) {
sbuf_printf(sb, "%s<access>%s</access>\n", indent, "read-only");
} else if ((sc->sc_flags & G_GATE_FLAG_WRITEONLY) != 0) {