Commit 395c67c1 authored by Zhouyang Jia's avatar Zhouyang Jia Committed by Greg Kroah-Hartman

xen: add error handling for xenbus_printf

[ Upstream commit 84c029a73327cef571eaa61c7d6e67e8031b52ec ]

When xenbus_printf fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling xenbus_printf.
Signed-off-by: 's avatarZhouyang Jia <jiazhouyang09@gmail.com>
Reviewed-by: 's avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: 's avatarJuergen Gross <jgross@suse.com>
Signed-off-by: 's avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 72bc7a2f
......@@ -292,8 +292,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
return;
}
if (sysrq_key != '\0')
xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
if (sysrq_key != '\0') {
err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
if (err) {
pr_err("%s: Error %d writing sysrq in control/sysrq\n",
__func__, err);
xenbus_transaction_end(xbt, 1);
return;
}
}
err = xenbus_transaction_end(xbt, 0);
if (err == -EAGAIN)
......@@ -345,7 +352,12 @@ static int setup_shutdown_watcher(void)
continue;
snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
shutdown_handlers[idx].command);
xenbus_printf(XBT_NIL, "control", node, "%u", 1);
err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
if (err) {
pr_err("%s: Error %d writing %s\n", __func__,
err, node);
return err;
}
}
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment