Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: xen-scsifront: 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: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Zhouyang Jia and committed by
Juergen Gross
93efbd39 6e3cc2a6

+26 -7
+26 -7
drivers/scsi/xen-scsifront.c
··· 654 654 static int scsifront_sdev_configure(struct scsi_device *sdev) 655 655 { 656 656 struct vscsifrnt_info *info = shost_priv(sdev->host); 657 + int err; 657 658 658 - if (info && current == info->curr) 659 - xenbus_printf(XBT_NIL, info->dev->nodename, 659 + if (info && current == info->curr) { 660 + err = xenbus_printf(XBT_NIL, info->dev->nodename, 660 661 info->dev_state_path, "%d", XenbusStateConnected); 662 + if (err) { 663 + xenbus_dev_error(info->dev, err, 664 + "%s: writing dev_state_path", __func__); 665 + return err; 666 + } 667 + } 661 668 662 669 return 0; 663 670 } ··· 672 665 static void scsifront_sdev_destroy(struct scsi_device *sdev) 673 666 { 674 667 struct vscsifrnt_info *info = shost_priv(sdev->host); 668 + int err; 675 669 676 - if (info && current == info->curr) 677 - xenbus_printf(XBT_NIL, info->dev->nodename, 670 + if (info && current == info->curr) { 671 + err = xenbus_printf(XBT_NIL, info->dev->nodename, 678 672 info->dev_state_path, "%d", XenbusStateClosed); 673 + if (err) 674 + xenbus_dev_error(info->dev, err, 675 + "%s: writing dev_state_path", __func__); 676 + } 679 677 } 680 678 681 679 static struct scsi_host_template scsifront_sht = { ··· 1015 1003 1016 1004 if (scsi_add_device(info->host, chn, tgt, lun)) { 1017 1005 dev_err(&dev->dev, "scsi_add_device\n"); 1018 - xenbus_printf(XBT_NIL, dev->nodename, 1006 + err = xenbus_printf(XBT_NIL, dev->nodename, 1019 1007 info->dev_state_path, 1020 1008 "%d", XenbusStateClosed); 1009 + if (err) 1010 + xenbus_dev_error(dev, err, 1011 + "%s: writing dev_state_path", __func__); 1021 1012 } 1022 1013 break; 1023 1014 case VSCSIFRONT_OP_DEL_LUN: ··· 1034 1019 } 1035 1020 break; 1036 1021 case VSCSIFRONT_OP_READD_LUN: 1037 - if (device_state == XenbusStateConnected) 1038 - xenbus_printf(XBT_NIL, dev->nodename, 1022 + if (device_state == XenbusStateConnected) { 1023 + err = xenbus_printf(XBT_NIL, dev->nodename, 1039 1024 info->dev_state_path, 1040 1025 "%d", XenbusStateConnected); 1026 + if (err) 1027 + xenbus_dev_error(dev, err, 1028 + "%s: writing dev_state_path", __func__); 1029 + } 1041 1030 break; 1042 1031 default: 1043 1032 break;