提交 84c029a7 编写于 作者: Z Zhouyang Jia 提交者: Juergen Gross

xen: add error handling for xenbus_printf

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: NZhouyang Jia <jiazhouyang09@gmail.com>
Reviewed-by: NBoris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: NJuergen Gross <jgross@suse.com>
上级 1fe83888
...@@ -289,8 +289,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path, ...@@ -289,8 +289,15 @@ static void sysrq_handler(struct xenbus_watch *watch, const char *path,
return; return;
} }
if (sysrq_key != '\0') if (sysrq_key != '\0') {
xenbus_printf(xbt, "control", "sysrq", "%c", '\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); err = xenbus_transaction_end(xbt, 0);
if (err == -EAGAIN) if (err == -EAGAIN)
...@@ -342,7 +349,12 @@ static int setup_shutdown_watcher(void) ...@@ -342,7 +349,12 @@ static int setup_shutdown_watcher(void)
continue; continue;
snprintf(node, FEATURE_PATH_SIZE, "feature-%s", snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
shutdown_handlers[idx].command); 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; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册