From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: Juergen Gross <jgross@suse.com>,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xen: add error handling for xenbus_printf
Date: Thu, 14 Jun 2018 17:57:39 -0400 [thread overview]
Message-ID: <8c85b8d8-0f29-d384-f3a4-c8257e67128b@oracle.com> (raw)
In-Reply-To: <1528775073-39322-1-git-send-email-jiazhouyang09@gmail.com>
On 06/11/2018 11:44 PM, Zhouyang Jia wrote:
> 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>
> ---
> 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);
Adding __func__ will make it it easier trying to understand where the
error is coming from. And for consistency, I'd add it to the one above
as well.
-boris
next prev parent reply other threads:[~2018-06-14 21:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 3:44 Zhouyang Jia
2018-06-14 21:57 ` Boris Ostrovsky [this message]
2018-06-14 23:34 ` [PATCH v2] " Zhouyang Jia
2018-06-15 12:54 ` Boris Ostrovsky
2018-06-19 13:02 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8c85b8d8-0f29-d384-f3a4-c8257e67128b@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=jiazhouyang09@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®