linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi
@ 2012-12-07  6:28 Dan Carpenter
  2012-12-07  8:41 ` Rolf Eike Beer
  2012-12-11  9:02 ` Reddy, Sreekanth
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-12-07  6:28 UTC (permalink / raw)
  To: Nagalakshmi Nandigama
  Cc: Sreekanth Reddy, support, James E.J. Bottomley,
	DL-MPTFusionLinux, linux-scsi, linux-kernel, kernel-janitors

ioc->diag_trigger_mpi is an SL_WH_MPI_TRIGGERS_T struct.

There is a cut and paste error here and SL_WH_EVENT_TRIGGERS_T is used
instead of SL_WH_MPI_TRIGGERS_T.  Since the SL_WH_EVENT_TRIGGERS_T is
smaller than SL_WH_MPI_TRIGGERS_T, it means we only clear part of the
buffer.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Only needed in linux-next.

This is a static analysis patch.  Even though I'm pretty sure it's
correct, I'm not able to test it.

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 8af944d..3e35e64 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3136,7 +3136,7 @@ _ctl_diag_trigger_mpi_store(struct device *cdev,
 	spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
 	sz = min(sizeof(struct SL_WH_MPI_TRIGGERS_T), count);
 	memset(&ioc->diag_trigger_mpi, 0,
-	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
+	    sizeof(struct SL_WH_MPI_TRIGGERS_T));
 	memcpy(&ioc->diag_trigger_mpi, buf, sz);
 	if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
 		ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;

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

* Re: [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi
  2012-12-07  6:28 [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi Dan Carpenter
@ 2012-12-07  8:41 ` Rolf Eike Beer
  2012-12-07 10:56   ` [patch v2] " Dan Carpenter
  2012-12-07 11:00   ` [patch] " Dan Carpenter
  2012-12-11  9:02 ` Reddy, Sreekanth
  1 sibling, 2 replies; 5+ messages in thread
From: Rolf Eike Beer @ 2012-12-07  8:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Nagalakshmi Nandigama, Sreekanth Reddy, support,
	James E.J. Bottomley, DL-MPTFusionLinux, linux-scsi,
	linux-kernel, kernel-janitors

> ioc->diag_trigger_mpi is an SL_WH_MPI_TRIGGERS_T struct.
>
> There is a cut and paste error here and SL_WH_EVENT_TRIGGERS_T is 
> used
> instead of SL_WH_MPI_TRIGGERS_T.  Since the SL_WH_EVENT_TRIGGERS_T is
> smaller than SL_WH_MPI_TRIGGERS_T, it means we only clear part of the
> buffer.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Only needed in linux-next.
>
> This is a static analysis patch.  Even though I'm pretty sure it's
> correct, I'm not able to test it.
>
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
> b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
> index 8af944d..3e35e64 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
> @@ -3136,7 +3136,7 @@ _ctl_diag_trigger_mpi_store(struct device 
> *cdev,
>  	spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
>  	sz = min(sizeof(struct SL_WH_MPI_TRIGGERS_T), count);
>  	memset(&ioc->diag_trigger_mpi, 0,
> -	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
> +	    sizeof(struct SL_WH_MPI_TRIGGERS_T));
>  	memcpy(&ioc->diag_trigger_mpi, buf, sz);
>  	if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
>  		ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;

Then just use sizeof(ioc->diag_trigger_mpi), then it's irrelevant how 
that type is ever called.

Eike

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

* [patch v2] [SCSI] mpt3sas: cut and paste bug storing trigger mpi
  2012-12-07  8:41 ` Rolf Eike Beer
@ 2012-12-07 10:56   ` Dan Carpenter
  2012-12-07 11:00   ` [patch] " Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-12-07 10:56 UTC (permalink / raw)
  To: Nagalakshmi Nandigama
  Cc: Sreekanth Reddy, support, James E.J. Bottomley,
	DL-MPTFusionLinux, linux-scsi, linux-kernel, kernel-janitors,
	Rolf Eike Beer

ioc->diag_trigger_mpi is an SL_WH_MPI_TRIGGERS_T struct.

There is a cut and paste error here and SL_WH_EVENT_TRIGGERS_T is used
instead of SL_WH_MPI_TRIGGERS_T.  Since the SL_WH_EVENT_TRIGGERS_T is
smaller than SL_WH_MPI_TRIGGERS_T, it means we only clear part of the
buffer.

I've changed it to use sizeof(ioc->diag_trigger_mpi) which is a bit
simpler.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Style tweak.

Only needed in linux-next.

This is a static analysis patch.  Even though I'm pretty sure it's
correct, I'm not able to test it.

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 8af944d..3e35e64 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3136,7 +3136,7 @@ _ctl_diag_trigger_mpi_store(struct device *cdev,
 	spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
 	sz = min(sizeof(struct SL_WH_MPI_TRIGGERS_T), count);
 	memset(&ioc->diag_trigger_mpi, 0,
-	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
+	    sizeof(ioc->diag_trigger_mpi));
 	memcpy(&ioc->diag_trigger_mpi, buf, sz);
 	if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
 		ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;


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

* Re: [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi
  2012-12-07  8:41 ` Rolf Eike Beer
  2012-12-07 10:56   ` [patch v2] " Dan Carpenter
@ 2012-12-07 11:00   ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-12-07 11:00 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: Nagalakshmi Nandigama, Sreekanth Reddy, support,
	James E.J. Bottomley, DL-MPTFusionLinux, linux-scsi,
	linux-kernel, kernel-janitors

On Fri, Dec 07, 2012 at 09:41:56AM +0100, Rolf Eike Beer wrote:
> > 	memset(&ioc->diag_trigger_mpi, 0,
> >-	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
> >+	    sizeof(struct SL_WH_MPI_TRIGGERS_T));
> > 	memcpy(&ioc->diag_trigger_mpi, buf, sz);
> > 	if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
> > 		ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;
> 
> Then just use sizeof(ioc->diag_trigger_mpi), then it's irrelevant
> how that type is ever called.
> 

Yeah, that's the way I would have prefered to write this as well.
It took me a while to verify that the intent here was not to clear
only part of the struct.  Using sizeof(variable_name) instead of
sizeof(type) is more readable.

But then you get into the thing where the line before uses
sizeof(type)...

Oh well, I've sent both styles and the maintainer can choose.  :)

regards,
dan carpenter


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

* RE: [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi
  2012-12-07  6:28 [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi Dan Carpenter
  2012-12-07  8:41 ` Rolf Eike Beer
@ 2012-12-11  9:02 ` Reddy, Sreekanth
  1 sibling, 0 replies; 5+ messages in thread
From: Reddy, Sreekanth @ 2012-12-11  9:02 UTC (permalink / raw)
  To: Dan Carpenter, Nandigama, Nagalakshmi
  Cc: Support, James E.J. Bottomley, DL-MPT Fusion Linux, linux-scsi,
	linux-kernel, kernel-janitors

James,

This patch seem to be fine. Please consider this patch as Acked-by: "Sreekanth Reddy" <Sreekanth.reddy@lsi.com>

Regards,
Sreekanth.

-----Original Message-----
From: Dan Carpenter [mailto:dan.carpenter@oracle.com] 
Sent: Friday, December 07, 2012 11:58 AM
To: Nandigama, Nagalakshmi
Cc: Reddy, Sreekanth; Support; James E.J. Bottomley; DL-MPT Fusion Linux; linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org; kernel-janitors@vger.kernel.org
Subject: [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi

ioc->diag_trigger_mpi is an SL_WH_MPI_TRIGGERS_T struct.

There is a cut and paste error here and SL_WH_EVENT_TRIGGERS_T is used instead of SL_WH_MPI_TRIGGERS_T.  Since the SL_WH_EVENT_TRIGGERS_T is smaller than SL_WH_MPI_TRIGGERS_T, it means we only clear part of the buffer.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Only needed in linux-next.

This is a static analysis patch.  Even though I'm pretty sure it's correct, I'm not able to test it.

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index 8af944d..3e35e64 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3136,7 +3136,7 @@ _ctl_diag_trigger_mpi_store(struct device *cdev,
 	spin_lock_irqsave(&ioc->diag_trigger_lock, flags);
 	sz = min(sizeof(struct SL_WH_MPI_TRIGGERS_T), count);
 	memset(&ioc->diag_trigger_mpi, 0,
-	    sizeof(struct SL_WH_EVENT_TRIGGERS_T));
+	    sizeof(struct SL_WH_MPI_TRIGGERS_T));
 	memcpy(&ioc->diag_trigger_mpi, buf, sz);
 	if (ioc->diag_trigger_mpi.ValidEntries > NUM_VALID_ENTRIES)
 		ioc->diag_trigger_mpi.ValidEntries = NUM_VALID_ENTRIES;

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

end of thread, other threads:[~2012-12-11  9:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-07  6:28 [patch] [SCSI] mpt3sas: cut and paste bug storing trigger mpi Dan Carpenter
2012-12-07  8:41 ` Rolf Eike Beer
2012-12-07 10:56   ` [patch v2] " Dan Carpenter
2012-12-07 11:00   ` [patch] " Dan Carpenter
2012-12-11  9:02 ` Reddy, Sreekanth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).