aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_pscsi.c
diff options
context:
space:
mode:
authorJoern Engel <joern@logfs.org>2014-09-02 17:50:00 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2014-09-17 18:20:57 -0400
commitce31c1b0dc4038a1dec64585d892adb73d9c45f4 (patch)
tree2c808d3d981f99f22fcafefddc716e79fc2faa5d /drivers/target/target_core_pscsi.c
parent68edbce4fb4b173d3b9880967cfcce0fc3abc8d5 (diff)
target: correctly handle match_int errors in FILEIO + PSCSI
This patch correctly handles match_int() errors in FILEIO + PSCSI backend parameter parsing, which can potentially fail due to a memory allocation failure or invalid argument. Found by coverity. Signed-off-by: Joern Engel <joern@logfs.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_pscsi.c')
-rw-r--r--drivers/target/target_core_pscsi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 943b1dbe859a..a1690a3fdd7f 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -749,14 +749,18 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_device *dev,
749 ret = -EINVAL; 749 ret = -EINVAL;
750 goto out; 750 goto out;
751 } 751 }
752 match_int(args, &arg); 752 ret = match_int(args, &arg);
753 if (ret)
754 goto out;
753 pdv->pdv_host_id = arg; 755 pdv->pdv_host_id = arg;
754 pr_debug("PSCSI[%d]: Referencing SCSI Host ID:" 756 pr_debug("PSCSI[%d]: Referencing SCSI Host ID:"
755 " %d\n", phv->phv_host_id, pdv->pdv_host_id); 757 " %d\n", phv->phv_host_id, pdv->pdv_host_id);
756 pdv->pdv_flags |= PDF_HAS_VIRT_HOST_ID; 758 pdv->pdv_flags |= PDF_HAS_VIRT_HOST_ID;
757 break; 759 break;
758 case Opt_scsi_channel_id: 760 case Opt_scsi_channel_id:
759 match_int(args, &arg); 761 ret = match_int(args, &arg);
762 if (ret)
763 goto out;
760 pdv->pdv_channel_id = arg; 764 pdv->pdv_channel_id = arg;
761 pr_debug("PSCSI[%d]: Referencing SCSI Channel" 765 pr_debug("PSCSI[%d]: Referencing SCSI Channel"
762 " ID: %d\n", phv->phv_host_id, 766 " ID: %d\n", phv->phv_host_id,
@@ -764,7 +768,9 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_device *dev,
764 pdv->pdv_flags |= PDF_HAS_CHANNEL_ID; 768 pdv->pdv_flags |= PDF_HAS_CHANNEL_ID;
765 break; 769 break;
766 case Opt_scsi_target_id: 770 case Opt_scsi_target_id:
767 match_int(args, &arg); 771 ret = match_int(args, &arg);
772 if (ret)
773 goto out;
768 pdv->pdv_target_id = arg; 774 pdv->pdv_target_id = arg;
769 pr_debug("PSCSI[%d]: Referencing SCSI Target" 775 pr_debug("PSCSI[%d]: Referencing SCSI Target"
770 " ID: %d\n", phv->phv_host_id, 776 " ID: %d\n", phv->phv_host_id,
@@ -772,7 +778,9 @@ static ssize_t pscsi_set_configfs_dev_params(struct se_device *dev,
772 pdv->pdv_flags |= PDF_HAS_TARGET_ID; 778 pdv->pdv_flags |= PDF_HAS_TARGET_ID;
773 break; 779 break;
774 case Opt_scsi_lun_id: 780 case Opt_scsi_lun_id:
775 match_int(args, &arg); 781 ret = match_int(args, &arg);
782 if (ret)
783 goto out;
776 pdv->pdv_lun_id = arg; 784 pdv->pdv_lun_id = arg;
777 pr_debug("PSCSI[%d]: Referencing SCSI LUN ID:" 785 pr_debug("PSCSI[%d]: Referencing SCSI LUN ID:"
778 " %d\n", phv->phv_host_id, pdv->pdv_lun_id); 786 " %d\n", phv->phv_host_id, pdv->pdv_lun_id);