summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2016-02-04 12:50:57 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2016-02-04 12:50:57 +0000
commit182a62370da94bf587305d08af9d00b5abedc1d5 (patch)
tree9d2fb8ee3b2dc7fc63ef01918dd976ac2c85e053 /sys/dev
parent12efd15a33b3f47ebe0e8d2755ca4aa7deeb78b6 (diff)
Bail early if there's no token; found by jsg@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pv/xenstore.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/dev/pv/xenstore.c b/sys/dev/pv/xenstore.c
index 95b1fdc7fa2..c759de82c1b 100644
--- a/sys/dev/pv/xenstore.c
+++ b/sys/dev/pv/xenstore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xenstore.c,v 1.25 2016/02/02 17:52:46 mikeb Exp $ */
+/* $OpenBSD: xenstore.c,v 1.26 2016/02/04 12:50:56 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -58,8 +58,7 @@
* notably the XenBus used to discover and manage Xen devices.
*/
-const struct
-{
+const struct {
const char *xse_errstr;
int xse_errnum;
} xs_errors[] = {
@@ -80,8 +79,7 @@ const struct
{ NULL, -1 },
};
-struct xs_msghdr
-{
+struct xs_msghdr {
/* Message type */
uint32_t xmh_type;
/* Request identifier, echoed in daemon's response. */
@@ -590,9 +588,7 @@ xs_intr(void *arg)
if (xsm->xsm_read == xsm->xsm_hdr.xmh_len) {
xs->xs_rmsg = NULL;
if (xsm->xsm_hdr.xmh_type == XS_EVENT) {
- if (xs_event(xs, xsm))
- printf("%s: no watchers for node \"%s\"\n",
- sc->sc_dev.dv_xname, xsm->xsm_data);
+ xs_event(xs, xsm);
} else {
mtx_enter(&xs->xs_rsplck);
TAILQ_INSERT_TAIL(&xs->xs_rsps, xsm, xsm_link);
@@ -691,7 +687,7 @@ int
xs_event(struct xs_softc *xs, struct xs_msg *xsm)
{
struct xs_watch *xsw;
- char *token;
+ char *token = NULL;
int i;
for (i = 0; i < xsm->xsm_read; i++) {
@@ -700,6 +696,11 @@ xs_event(struct xs_softc *xs, struct xs_msg *xsm)
break;
}
}
+ if (token == NULL) {
+ printf("%s: event on \"%s\" without token\n",
+ xs->xs_sc->sc_dev.dv_xname, xsm->xsm_data);
+ return (-1);
+ }
mtx_enter(&xs->xs_watchlck);
TAILQ_FOREACH(xsw, &xs->xs_watches, xsw_entry) {
@@ -710,6 +711,9 @@ xs_event(struct xs_softc *xs, struct xs_msg *xsm)
return (0);
}
mtx_leave(&xs->xs_watchlck);
+
+ printf("%s: no watchers for node \"%s\"\n",
+ xs->xs_sc->sc_dev.dv_xname, xsm->xsm_data);
return (-1);
}