summaryrefslogtreecommitdiffstats
path: root/drivers/xen/manage.c
diff options
context:
space:
mode:
authorZhouyang Jia <jiazhouyang09@gmail.com>2018-06-14 19:34:52 -0400
committerJuergen Gross <jgross@suse.com>2018-06-19 08:27:41 -0400
commit84c029a73327cef571eaa61c7d6e67e8031b52ec (patch)
tree1507bbe45e47955e2d88a829c195a790682f036d /drivers/xen/manage.c
parent1fe83888a2b776c204cb06629700adfb8e9cc123 (diff)
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@gmail.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'drivers/xen/manage.c')
-rw-r--r--drivers/xen/manage.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index 8835065029d3..c93d8ef8df34 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,
289 return; 289 return;
290 } 290 }
291 291
292 if (sysrq_key != '\0') 292 if (sysrq_key != '\0') {
293 xenbus_printf(xbt, "control", "sysrq", "%c", '\0'); 293 err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
294 if (err) {
295 pr_err("%s: Error %d writing sysrq in control/sysrq\n",
296 __func__, err);
297 xenbus_transaction_end(xbt, 1);
298 return;
299 }
300 }
294 301
295 err = xenbus_transaction_end(xbt, 0); 302 err = xenbus_transaction_end(xbt, 0);
296 if (err == -EAGAIN) 303 if (err == -EAGAIN)
@@ -342,7 +349,12 @@ static int setup_shutdown_watcher(void)
342 continue; 349 continue;
343 snprintf(node, FEATURE_PATH_SIZE, "feature-%s", 350 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
344 shutdown_handlers[idx].command); 351 shutdown_handlers[idx].command);
345 xenbus_printf(XBT_NIL, "control", node, "%u", 1); 352 err = xenbus_printf(XBT_NIL, "control", node, "%u", 1);
353 if (err) {
354 pr_err("%s: Error %d writing %s\n", __func__,
355 err, node);
356 return err;
357 }
346 } 358 }
347 359
348 return 0; 360 return 0;