[PATCH] xenbus: check return value of xenbus_scanf()
From: Jan Beulich
Date: Thu Jul 07 2016 - 03:42:31 EST
Set backend state to unknown when unsuccessful.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
drivers/xen/xenbus/xenbus_probe_frontend.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- 4.7-rc6-xenbus_scanf.orig/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ 4.7-rc6-xenbus_scanf/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -342,7 +342,9 @@ static int backend_state;
static void xenbus_reset_backend_state_changed(struct xenbus_watch *w,
const char **v, unsigned int l)
{
- xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i", &backend_state);
+ if (xenbus_scanf(XBT_NIL, v[XS_WATCH_PATH], "", "%i",
+ &backend_state) != 1)
+ backend_state = XenbusStateUnknown;
printk(KERN_DEBUG "XENBUS: backend %s %s\n",
v[XS_WATCH_PATH], xenbus_strstate(backend_state));
wake_up(&backend_state_wq);