From be00f071cddc9f9c2bbae5eb596284e01d71a525 Mon Sep 17 00:00:00 2001 From: trociny Date: Tue, 7 Aug 2012 18:50:33 +0000 Subject: 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 --- sys/geom/gate/g_gate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sys/geom/gate') diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c index 7282ac9..d1ddd40 100644 --- a/sys/geom/gate/g_gate.c +++ b/sys/geom/gate/g_gate.c @@ -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%s\n", indent, "read-only"); } else if ((sc->sc_flags & G_GATE_FLAG_WRITEONLY) != 0) { -- cgit v1.1