diff options
author | Joern Engel <joern@logfs.org> | 2014-09-02 17:50:00 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-09-17 18:20:57 -0400 |
commit | ce31c1b0dc4038a1dec64585d892adb73d9c45f4 (patch) | |
tree | 2c808d3d981f99f22fcafefddc716e79fc2faa5d | |
parent | 68edbce4fb4b173d3b9880967cfcce0fc3abc8d5 (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>
-rw-r--r-- | drivers/target/target_core_file.c | 4 | ||||
-rw-r--r-- | drivers/target/target_core_pscsi.c | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 7d6cddaec525..ab2c53b63cc3 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c | |||
@@ -762,7 +762,9 @@ static ssize_t fd_set_configfs_dev_params(struct se_device *dev, | |||
762 | fd_dev->fbd_flags |= FBDF_HAS_SIZE; | 762 | fd_dev->fbd_flags |= FBDF_HAS_SIZE; |
763 | break; | 763 | break; |
764 | case Opt_fd_buffered_io: | 764 | case Opt_fd_buffered_io: |
765 | match_int(args, &arg); | 765 | ret = match_int(args, &arg); |
766 | if (ret) | ||
767 | goto out; | ||
766 | if (arg != 1) { | 768 | if (arg != 1) { |
767 | pr_err("bogus fd_buffered_io=%d value\n", arg); | 769 | pr_err("bogus fd_buffered_io=%d value\n", arg); |
768 | ret = -EINVAL; | 770 | ret = -EINVAL; |
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); |