Linux SCSI subsystem development
 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: [PATCH 6/9] libosd: bug in osd_req_decode_sense_full()
Date: Mon, 16 Nov 2009 20:47:07 +0200	[thread overview]
Message-ID: <1258397227-32739-1-git-send-email-bharrosh@panasas.com> (raw)
In-Reply-To: <4B019BEC.3080909@panasas.com>

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 |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 60b7ca1..5e90d19 100644
--- a/drivers/scsi/osd/osd_initiator.c
+++ b/drivers/scsi/osd/osd_initiator.c
@@ -1583,15 +1583,14 @@ 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);
-			int i = 0;
+			unsigned len = min(cur_len, sense_len);
 			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",
-- 
1.6.5.2


  parent reply	other threads:[~2009-11-16 18:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-16 18:37 [PATCHES 0/9] osd patches for 2.6.33 merge window - resend Boaz Harrosh
2009-11-16 18:39 ` [PATCH 1/9] libosd: osd_dev_is_ver1 - Minor API cleanup Boaz Harrosh
2009-11-16 18:41 ` [PATCH 2/9] libosd: osd_sense: OSD_CFO_PERMISSIONS Boaz Harrosh
2009-11-16 18:44 ` [PATCH 3/9] osduld: Ref-counting bug fix Boaz Harrosh
2009-11-16 18:45 ` [PATCH 4/9] osduld: Use device->release instead of internal kref Boaz Harrosh
2009-11-16 19:52   ` James Bottomley
2009-11-16 18:45 ` [PATCH 5/9] libosd: osd_dev_info: Unique Identification of an OSD device Boaz Harrosh
2009-11-16 18:47 ` Boaz Harrosh [this message]
2009-11-16 18:47 ` [PATCH 7/9] libosd: Bugfix of error handling in attributes-list decoding Boaz Harrosh
2009-11-16 18:48 ` [PATCH 8/9] libosd: Error handling revamped Boaz Harrosh
2009-11-16 18:49 ` [PATCH 9/9] osd_protocol.h: Add missing #include Boaz Harrosh
2009-11-16 18:57   ` Martin Michlmayr
2009-11-16 19:01     ` Boaz Harrosh
2009-11-16 19:09       ` Martin Michlmayr
2009-11-16 20:01       ` James Bottomley
2009-11-17  7:54         ` Boaz Harrosh
2009-11-17 13:50 ` [PATCH 10/10] osduld: No need to use dev_set_drvdata on embedded devices Boaz Harrosh
2009-11-23 16:34 ` [osd-dev] [PATCHES 0/9] osd patches for 2.6.33 merge window - resend 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=1258397227-32739-1-git-send-email-bharrosh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox