aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2009-11-16 13:47:07 -0500
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 13:01:46 -0500
commit71ecb74b15377a6c0e0e6ea95d4b549580fb4d48 (patch)
tree0fb410841016fc0b52821641ef32a06fcd443d2f /drivers/scsi
parent2cdd6410e5a1665823f2a048fc7f8f6a8384be1d (diff)
[SCSI] libosd: bug in osd_req_decode_sense_full()
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> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/osd/osd_initiator.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/scsi/osd/osd_initiator.c b/drivers/scsi/osd/osd_initiator.c
index 60b7ca1e9bc0..5e90d19fddf8 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,
1583 { 1583 {
1584 struct osd_sense_attributes_data_descriptor 1584 struct osd_sense_attributes_data_descriptor
1585 *osadd = cur_descriptor; 1585 *osadd = cur_descriptor;
1586 int len = min(cur_len, sense_len); 1586 unsigned len = min(cur_len, sense_len);
1587 int i = 0;
1588 struct osd_sense_attr *pattr = osadd->sense_attrs; 1587 struct osd_sense_attr *pattr = osadd->sense_attrs;
1589 1588
1590 while (len < 0) { 1589 while (len >= sizeof(*pattr)) {
1591 u32 attr_page = be32_to_cpu(pattr->attr_page); 1590 u32 attr_page = be32_to_cpu(pattr->attr_page);
1592 u32 attr_id = be32_to_cpu(pattr->attr_id); 1591 u32 attr_id = be32_to_cpu(pattr->attr_id);
1593 1592
1594 if (i++ == 0) { 1593 if (!osi->attr.attr_page) {
1595 osi->attr.attr_page = attr_page; 1594 osi->attr.attr_page = attr_page;
1596 osi->attr.attr_id = attr_id; 1595 osi->attr.attr_id = attr_id;
1597 } 1596 }
@@ -1602,6 +1601,8 @@ int osd_req_decode_sense_full(struct osd_request *or,
1602 bad_attr_list++; 1601 bad_attr_list++;
1603 max_attr--; 1602 max_attr--;
1604 } 1603 }
1604
1605 len -= sizeof(*pattr);
1605 OSD_SENSE_PRINT2( 1606 OSD_SENSE_PRINT2(
1606 "osd_sense_attribute_identification" 1607 "osd_sense_attribute_identification"
1607 "attr_page=0x%x attr_id=0x%x\n", 1608 "attr_page=0x%x attr_id=0x%x\n",