[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: add error handling for xenbus_printf



Hi,

Sorry, I can't find which xenbus_device to print. So I inherit the existing
style and use pr_err.

I add __func__ in v2. If it needs to be changed, please let me know.

Thanks for your kind reply.

Best,
Zhouyang

2018-06-15 5:57 GMT+08:00 Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>:
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@xxxxxxxxx>
> ---
>  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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.