Skip to content

Commit

Permalink
xen/scsiback: add error handling for xenbus_printf
Browse files Browse the repository at this point in the history
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: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
  • Loading branch information
Zhouyang Jia authored and Juergen Gross committed Jun 19, 2018
1 parent 93efbd3 commit 7c63ca2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions drivers/xen/xen-scsiback.c
Original file line number Diff line number Diff line change
@@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
{
struct v2p_entry *entry;
unsigned long flags;
int err;

if (try) {
spin_lock_irqsave(&info->v2p_lock, flags);
@@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
scsiback_del_translation_entry(info, vir);
}
} else if (!try) {
xenbus_printf(XBT_NIL, info->dev->nodename, state,
err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
"%d", XenbusStateClosed);
if (err)
xenbus_dev_error(info->dev, err,
"%s: writing %s", __func__, state);
}
}

@@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
if (IS_ERR(val)) {
xenbus_printf(XBT_NIL, dev->nodename, state,
err = xenbus_printf(XBT_NIL, dev->nodename, state,
"%d", XenbusStateClosed);
if (err)
xenbus_dev_error(info->dev, err,
"%s: writing %s", __func__, state);
return;
}
strlcpy(phy, val, VSCSI_NAMELEN);
@@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
&vir.hst, &vir.chn, &vir.tgt, &vir.lun);
if (XENBUS_EXIST_ERR(err)) {
xenbus_printf(XBT_NIL, dev->nodename, state,
err = xenbus_printf(XBT_NIL, dev->nodename, state,
"%d", XenbusStateClosed);
if (err)
xenbus_dev_error(info->dev, err,
"%s: writing %s", __func__, state);
return;
}

0 comments on commit 7c63ca2

Please sign in to comment.