All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mvsas: don't allow negative timeouts
@ 2015-11-13 14:23 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-11-13 14:23 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Hannes Reinecke, Dan Williams, Bart Van Assche,
	Martin K. Petersen, Johannes Thumshirn, Jack Wang, linux-scsi,
	kernel-janitors

There is a static checker warning here because "val" is controlled by
the user and we have a upper bound on it but allow negative numbers.
"val" appears to be a timeout in usec so this bug probably means we
have a longer timeout than we should.  Let's fix this by changing "val"
to unsigned.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Checkpatch has several complaints about this code but I left it as-is.

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 90fdf0e..675e7fa 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -758,7 +758,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
 			struct device_attribute *attr,
 			const char *buffer, size_t size)
 {
-	int val = 0;
+	unsigned int val = 0;
 	struct mvs_info *mvi = NULL;
 	struct Scsi_Host *shost = class_to_shost(cdev);
 	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
@@ -766,7 +766,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
 	if (buffer = NULL)
 		return size;
 
-	if (sscanf(buffer, "%d", &val) != 1)
+	if (sscanf(buffer, "%u", &val) != 1)
 		return -EINVAL;
 
 	if (val >= 0x10000) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [patch] mvsas: don't allow negative timeouts
@ 2015-11-13 14:23 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2015-11-13 14:23 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Hannes Reinecke, Dan Williams, Bart Van Assche,
	Martin K. Petersen, Johannes Thumshirn, Jack Wang, linux-scsi,
	kernel-janitors

There is a static checker warning here because "val" is controlled by
the user and we have a upper bound on it but allow negative numbers.
"val" appears to be a timeout in usec so this bug probably means we
have a longer timeout than we should.  Let's fix this by changing "val"
to unsigned.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Checkpatch has several complaints about this code but I left it as-is.

diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
index 90fdf0e..675e7fa 100644
--- a/drivers/scsi/mvsas/mv_init.c
+++ b/drivers/scsi/mvsas/mv_init.c
@@ -758,7 +758,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
 			struct device_attribute *attr,
 			const char *buffer, size_t size)
 {
-	int val = 0;
+	unsigned int val = 0;
 	struct mvs_info *mvi = NULL;
 	struct Scsi_Host *shost = class_to_shost(cdev);
 	struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
@@ -766,7 +766,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
 	if (buffer == NULL)
 		return size;
 
-	if (sscanf(buffer, "%d", &val) != 1)
+	if (sscanf(buffer, "%u", &val) != 1)
 		return -EINVAL;
 
 	if (val >= 0x10000) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [patch] mvsas: don't allow negative timeouts
  2015-11-13 14:23 ` Dan Carpenter
@ 2015-11-13 15:20   ` Jinpu Wang
  -1 siblings, 0 replies; 6+ messages in thread
From: Jinpu Wang @ 2015-11-13 15:20 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: James E.J. Bottomley, Hannes Reinecke, Dan Williams,
	Bart Van Assche, Martin K. Petersen, Johannes Thumshirn,
	linux-scsi, kernel-janitors

On Fri, Nov 13, 2015 at 3:23 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> There is a static checker warning here because "val" is controlled by
> the user and we have a upper bound on it but allow negative numbers.
> "val" appears to be a timeout in usec so this bug probably means we
> have a longer timeout than we should.  Let's fix this by changing "val"
> to unsigned.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Checkpatch has several complaints about this code but I left it as-is.
>
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index 90fdf0e..675e7fa 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -758,7 +758,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
>                         struct device_attribute *attr,
>                         const char *buffer, size_t size)
>  {
> -       int val = 0;
> +       unsigned int val = 0;
>         struct mvs_info *mvi = NULL;
>         struct Scsi_Host *shost = class_to_shost(cdev);
>         struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> @@ -766,7 +766,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
>         if (buffer = NULL)
>                 return size;
>
> -       if (sscanf(buffer, "%d", &val) != 1)
> +       if (sscanf(buffer, "%u", &val) != 1)
>                 return -EINVAL;
>
>         if (val >= 0x10000) {

Looks good to me.
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>

-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mvsas: don't allow negative timeouts
@ 2015-11-13 15:20   ` Jinpu Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Jinpu Wang @ 2015-11-13 15:20 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: James E.J. Bottomley, Hannes Reinecke, Dan Williams,
	Bart Van Assche, Martin K. Petersen, Johannes Thumshirn,
	linux-scsi, kernel-janitors

On Fri, Nov 13, 2015 at 3:23 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> There is a static checker warning here because "val" is controlled by
> the user and we have a upper bound on it but allow negative numbers.
> "val" appears to be a timeout in usec so this bug probably means we
> have a longer timeout than we should.  Let's fix this by changing "val"
> to unsigned.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Checkpatch has several complaints about this code but I left it as-is.
>
> diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
> index 90fdf0e..675e7fa 100644
> --- a/drivers/scsi/mvsas/mv_init.c
> +++ b/drivers/scsi/mvsas/mv_init.c
> @@ -758,7 +758,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
>                         struct device_attribute *attr,
>                         const char *buffer, size_t size)
>  {
> -       int val = 0;
> +       unsigned int val = 0;
>         struct mvs_info *mvi = NULL;
>         struct Scsi_Host *shost = class_to_shost(cdev);
>         struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost);
> @@ -766,7 +766,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
>         if (buffer == NULL)
>                 return size;
>
> -       if (sscanf(buffer, "%d", &val) != 1)
> +       if (sscanf(buffer, "%u", &val) != 1)
>                 return -EINVAL;
>
>         if (val >= 0x10000) {

Looks good to me.
Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>

-- 
Mit freundlichen Grüßen,
Best Regards,

Jack Wang

Linux Kernel Developer Storage
ProfitBricks GmbH  The IaaS-Company.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mvsas: don't allow negative timeouts
  2015-11-13 14:23 ` Dan Carpenter
@ 2015-11-13 20:46   ` Martin K. Petersen
  -1 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2015-11-13 20:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: James E.J. Bottomley, Hannes Reinecke, Dan Williams,
	Bart Van Assche, Martin K. Petersen, Johannes Thumshirn,
	Jack Wang, linux-scsi, kernel-janitors

>>>>> "Dan" = Dan Carpenter <dan.carpenter@oracle.com> writes:

Dan> There is a static checker warning here because "val" is controlled
Dan> by the user and we have a upper bound on it but allow negative
Dan> numbers.  "val" appears to be a timeout in usec so this bug
Dan> probably means we have a longer timeout than we should.  Let's fix
Dan> this by changing "val" to unsigned.

Applied.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [patch] mvsas: don't allow negative timeouts
@ 2015-11-13 20:46   ` Martin K. Petersen
  0 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2015-11-13 20:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: James E.J. Bottomley, Hannes Reinecke, Dan Williams,
	Bart Van Assche, Martin K. Petersen, Johannes Thumshirn,
	Jack Wang, linux-scsi, kernel-janitors

>>>>> "Dan" == Dan Carpenter <dan.carpenter@oracle.com> writes:

Dan> There is a static checker warning here because "val" is controlled
Dan> by the user and we have a upper bound on it but allow negative
Dan> numbers.  "val" appears to be a timeout in usec so this bug
Dan> probably means we have a longer timeout than we should.  Let's fix
Dan> this by changing "val" to unsigned.

Applied.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-13 20:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 14:23 [patch] mvsas: don't allow negative timeouts Dan Carpenter
2015-11-13 14:23 ` Dan Carpenter
2015-11-13 15:20 ` Jinpu Wang
2015-11-13 15:20   ` Jinpu Wang
2015-11-13 20:46 ` Martin K. Petersen
2015-11-13 20:46   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.