All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: James Bottomley <James.Bottomley@hansenpartnership.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	open-osd <osd-dev@open-osd.org>
Subject: Re: [osd-dev] [PATCH 1/2] libosd: bug in osd_req_decode_sense_full()
Date: Tue, 10 Nov 2009 17:09:01 +0200	[thread overview]
Message-ID: <4AF9820D.3080401@panasas.com> (raw)
In-Reply-To: <4AF6B9B1.5040002@panasas.com>

On 11/08/2009 02:29 PM, Boaz Harrosh wrote:
> 
> The (never tested) osd_sense_attribute_identification case
> has never worked. The loop was never advanced on.
> Fix it to work as intended.
> 
> On 10/30/2009 04:39 PM, Roel Kluin wrote:
>   I found this by code analysis, searching for while
>   loops that test a local variable, but do not modify
>   the variable.
> 
> Reported-by: Roel Kluin <roel.kluin@gmail.com>
> Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
> ---
>  drivers/scsi/osd/osd_initiator.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
> index 60b7ca1..d504e82 100644
> --- a/drivers/scsi/osd/osd_initiator.c
> +++ b/drivers/scsi/osd/osd_initiator.c
> @@ -1584,14 +1584,13 @@ int osd_req_decode_sense_full(struct osd_request *or,
>  			struct osd_sense_attributes_data_descriptor
>  				*osadd = cur_descriptor;
>  			int len = min(cur_len, sense_len);

len should be unsigned for the compare with sizeof() below.

I'll repost a second version as reply.

Boaz
> -			int i = 0;
>  			struct osd_sense_attr *pattr = osadd->sense_attrs;
>  
> -			while (len < 0) {
> +			while (len >= sizeof(*pattr)) {
>  				u32 attr_page = be32_to_cpu(pattr->attr_page);
>  				u32 attr_id = be32_to_cpu(pattr->attr_id);
>  
> -				if (i++ == 0) {
> +				if (!osi->attr.attr_page) {
>  					osi->attr.attr_page = attr_page;
>  					osi->attr.attr_id = attr_id;
>  				}
> @@ -1602,6 +1601,8 @@ int osd_req_decode_sense_full(struct osd_request *or,
>  					bad_attr_list++;
>  					max_attr--;
>  				}
> +
> +				len -= sizeof(*pattr);
>  				OSD_SENSE_PRINT2(
>  					"osd_sense_attribute_identification"
>  					"attr_page=0x%x attr_id=0x%x\n",


  reply	other threads:[~2009-11-10 15:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-08 12:27 [PATCH 0/2] libosd: bug fixes Boaz Harrosh
2009-11-08 12:29 ` [PATCH 1/2] libosd: bug in osd_req_decode_sense_full() Boaz Harrosh
2009-11-10 15:09   ` Boaz Harrosh [this message]
2009-11-10 15:10   ` [PATCH1/2 version2] " Boaz Harrosh
2009-11-08 12:30 ` [PATCH 2/2] libosd: Bugfix of error handling in attributes-list decoding Boaz Harrosh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AF9820D.3080401@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=osd-dev@open-osd.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.