Skip to content

Commit 7c63ca2

Browse files
ZhouyangJiajgross1
authored andcommitted
xen/scsiback: 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 <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 93efbd3 commit 7c63ca2

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/xen/xen-scsiback.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
10121012
{
10131013
struct v2p_entry *entry;
10141014
unsigned long flags;
1015+
int err;
10151016

10161017
if (try) {
10171018
spin_lock_irqsave(&info->v2p_lock, flags);
@@ -1027,8 +1028,11 @@ static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
10271028
scsiback_del_translation_entry(info, vir);
10281029
}
10291030
} else if (!try) {
1030-
xenbus_printf(XBT_NIL, info->dev->nodename, state,
1031+
err = xenbus_printf(XBT_NIL, info->dev->nodename, state,
10311032
"%d", XenbusStateClosed);
1033+
if (err)
1034+
xenbus_dev_error(info->dev, err,
1035+
"%s: writing %s", __func__, state);
10321036
}
10331037
}
10341038

@@ -1067,8 +1071,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
10671071
snprintf(str, sizeof(str), "vscsi-devs/%s/p-dev", ent);
10681072
val = xenbus_read(XBT_NIL, dev->nodename, str, NULL);
10691073
if (IS_ERR(val)) {
1070-
xenbus_printf(XBT_NIL, dev->nodename, state,
1074+
err = xenbus_printf(XBT_NIL, dev->nodename, state,
10711075
"%d", XenbusStateClosed);
1076+
if (err)
1077+
xenbus_dev_error(info->dev, err,
1078+
"%s: writing %s", __func__, state);
10721079
return;
10731080
}
10741081
strlcpy(phy, val, VSCSI_NAMELEN);
@@ -1079,8 +1086,11 @@ static void scsiback_do_1lun_hotplug(struct vscsibk_info *info, int op,
10791086
err = xenbus_scanf(XBT_NIL, dev->nodename, str, "%u:%u:%u:%u",
10801087
&vir.hst, &vir.chn, &vir.tgt, &vir.lun);
10811088
if (XENBUS_EXIST_ERR(err)) {
1082-
xenbus_printf(XBT_NIL, dev->nodename, state,
1089+
err = xenbus_printf(XBT_NIL, dev->nodename, state,
10831090
"%d", XenbusStateClosed);
1091+
if (err)
1092+
xenbus_dev_error(info->dev, err,
1093+
"%s: writing %s", __func__, state);
10841094
return;
10851095
}
10861096

0 commit comments

Comments
 (0)