Skip to content

Commit

Permalink
[SCSI] Fix VPD inquiry page wrapper
Browse files Browse the repository at this point in the history
Fix two bugs in the VPD page wrapper:

    - Don't return failure if the user asked for page 0

    - The end of buffer check failed to account for the page header size
      and consequently didn't work

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Martin K. Petersen authored and James Bottomley committed Sep 16, 2010
1 parent 9c03f16 commit 16d3ea2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,13 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,

/* If the user actually wanted this page, we can skip the rest */
if (page == 0)
return -EINVAL;
return 0;

for (i = 0; i < min((int)buf[3], buf_len - 4); i++)
if (buf[i + 4] == page)
goto found;

if (i < buf[3] && i > buf_len)
if (i < buf[3] && i >= buf_len - 4)
/* ran off the end of the buffer, give us benefit of doubt */
goto found;
/* The device claims it doesn't support the requested page */
Expand Down

0 comments on commit 16d3ea2

Please sign in to comment.