linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] osst: wrong index used in inner loop
@ 2011-03-19 19:53 roel
  2011-03-21  1:02 ` FUJITA Tomonori
  0 siblings, 1 reply; 3+ messages in thread
From: roel @ 2011-03-19 19:53 UTC (permalink / raw)
  To: James E.J. Bottomley, linux-scsi, Andrew Morton, LKML

Index i was already used in the outer loop.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/scsi/osst.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

I'm not sure if this is the right fix, maybe a break or return
is missing?

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 521e218..d6d6d89 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -4702,8 +4702,9 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
 				STp->partition = STp->new_partition = 0;
 				if (STp->can_partitions)
 					STp->nbr_partitions = 1;  /* This guess will be updated later if necessary */
-				for (i=0; i < ST_NBR_PARTITIONS; i++) {
-					STps = &(STp->ps[i]);
+				int j;
+				for (j=0; j < ST_NBR_PARTITIONS; j++) {
+					STps = &(STp->ps[j]);
 					STps->rw = ST_IDLE;
 					STps->eof = ST_NOEOF;
 					STps->at_sm = 0;

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

* Re: [PATCH] osst: wrong index used in inner loop
  2011-03-19 19:53 [PATCH] osst: wrong index used in inner loop roel
@ 2011-03-21  1:02 ` FUJITA Tomonori
  2011-03-21 11:00   ` roel
  0 siblings, 1 reply; 3+ messages in thread
From: FUJITA Tomonori @ 2011-03-21  1:02 UTC (permalink / raw)
  To: roel.kluin; +Cc: James.Bottomley, linux-scsi, akpm, linux-kernel

On Sat, 19 Mar 2011 20:53:53 +0100
roel <roel.kluin@gmail.com> wrote:

> Index i was already used in the outer loop.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
>  drivers/scsi/osst.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> I'm not sure if this is the right fix, maybe a break or return
> is missing?

What are you trying to fix with this patch?


> diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
> index 521e218..d6d6d89 100644
> --- a/drivers/scsi/osst.c
> +++ b/drivers/scsi/osst.c
> @@ -4702,8 +4702,9 @@ static int __os_scsi_tape_open(struct inode * inode, struct file * filp)
>  				STp->partition = STp->new_partition = 0;
>  				if (STp->can_partitions)
>  					STp->nbr_partitions = 1;  /* This guess will be updated later if necessary */
> -				for (i=0; i < ST_NBR_PARTITIONS; i++) {
> -					STps = &(STp->ps[i]);
> +				int j;
> +				for (j=0; j < ST_NBR_PARTITIONS; j++) {
> +					STps = &(STp->ps[j]);
>  					STps->rw = ST_IDLE;
>  					STps->eof = ST_NOEOF;
>  					STps->at_sm = 0;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 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] 3+ messages in thread

* Re: [PATCH] osst: wrong index used in inner loop
  2011-03-21  1:02 ` FUJITA Tomonori
@ 2011-03-21 11:00   ` roel
  0 siblings, 0 replies; 3+ messages in thread
From: roel @ 2011-03-21 11:00 UTC (permalink / raw)
  To: FUJITA Tomonori; +Cc: James.Bottomley, linux-scsi, akpm, linux-kernel

On 21-03-11 02:02, FUJITA Tomonori wrote:
> On Sat, 19 Mar 2011 20:53:53 +0100
> roel <roel.kluin@gmail.com> wrote:
> 
>> Index i was already used in the outer loop.
>>
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>> ---
>>  drivers/scsi/osst.c |    5 +++--
>>  1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> I'm not sure if this is the right fix, maybe a break or return
>> is missing?
> 
> What are you trying to fix with this patch?

`i' is used as an index in both the outer loop at 4689 and the
inner loop at 4705.

if the UNIT_ATTENTION branch is taken `i' is overwritten after the
loop at 4705 and becomes ST_NBR_PARTITIONS + 1, i.e. 5.

So the loop at 4689 may not loop ten times when the UNIT_ATTENTION
branch is taken. It may loop 5 times or more than ten or hot spin,
dependent how often the UNIT_ATTENTION branch is taken. I'm not
familiar with this driver, but it looked buggy to me.

Roel

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

end of thread, other threads:[~2011-03-21 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-19 19:53 [PATCH] osst: wrong index used in inner loop roel
2011-03-21  1:02 ` FUJITA Tomonori
2011-03-21 11:00   ` roel

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).