diff mbox series

scsi: qla2xxx: don't allow negative thresholds

Message ID 20180920100236.GB9551@mwanda (mailing list archive)
State Accepted
Headers show
Series scsi: qla2xxx: don't allow negative thresholds | expand

Commit Message

Dan Carpenter Sept. 20, 2018, 10:02 a.m. UTC
We shouldn't allow negative thresholds.  I don't know what it would do
but it can't be good.

Fixes: 8b4673ba3a1b ("scsi: qla2xxx: Add support for ZIO6 interrupt threshold")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Madhani, Himanshu Sept. 26, 2018, 4:26 p.m. UTC | #1
> On Sep 20, 2018, at 3:02 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> External Email
> 
> We shouldn't allow negative thresholds.  I don't know what it would do
> but it can't be good.
> 
> Fixes: 8b4673ba3a1b ("scsi: qla2xxx: Add support for ZIO6 interrupt threshold")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
> index a31d23905753..b28f159fdaee 100644
> --- a/drivers/scsi/qla2xxx/qla_attr.c
> +++ b/drivers/scsi/qla2xxx/qla_attr.c
> @@ -1228,7 +1228,7 @@ qla_zio_threshold_store(struct device *dev, struct device_attribute *attr,
>                return -EINVAL;
>        if (sscanf(buf, "%d", &val) != 1)
>                return -EINVAL;
> -       if (val > 256)
> +       if (val < 0 || val > 256)
>                return -ERANGE;
> 
>        atomic_set(&vha->hw->zio_threshold, val);

Looks Good. 

Acked-by: Himanshu Madhani <himanshu.madhani@cavium.com>

Thanks,
- Himanshu
Martin K. Petersen Sept. 27, 2018, 11:51 p.m. UTC | #2
Dan,

> We shouldn't allow negative thresholds.  I don't know what it would do
> but it can't be good.

Applied to 4.20/scsi-queue, thanks!
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index a31d23905753..b28f159fdaee 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -1228,7 +1228,7 @@  qla_zio_threshold_store(struct device *dev, struct device_attribute *attr,
 		return -EINVAL;
 	if (sscanf(buf, "%d", &val) != 1)
 		return -EINVAL;
-	if (val > 256)
+	if (val < 0 || val > 256)
 		return -ERANGE;
 
 	atomic_set(&vha->hw->zio_threshold, val);