[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1528775073-39322-1-git-send-email-jiazhouyang09@gmail.com>
Date: Tue, 12 Jun 2018 11:44:33 +0800
From: Zhouyang Jia <jiazhouyang09@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@...il.com>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Juergen Gross <jgross@...e.com>,
xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org
Subject: [PATCH] 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: Zhouyang Jia <jiazhouyang09@...il.com>
---
drivers/xen/manage.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 8835065..159694d 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -289,8 +289,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("Error %d writing sysrq code in control/sysrq\n",
+ err);
+ xenbus_transaction_end(xbt, 1);
+ return;
+ }
+ }
err = xenbus_transaction_end(xbt, 0);
if (err == -EAGAIN)
@@ -342,7 +349,11 @@ 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("Error %d writing %s\n", err, node);
+ return err;
+ }
}
return 0;
--
2.7.4
Powered by blists - more mailing lists