Commit 16d3ea26 authored by Martin K. Petersen's avatar Martin K. Petersen Committed by James Bottomley

[SCSI] Fix VPD inquiry page wrapper

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: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Cc: Stable Tree <stable@kernel.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 9c03f162
...@@ -1046,13 +1046,13 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf, ...@@ -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 the user actually wanted this page, we can skip the rest */
if (page == 0) if (page == 0)
return -EINVAL; return 0;
for (i = 0; i < min((int)buf[3], buf_len - 4); i++) for (i = 0; i < min((int)buf[3], buf_len - 4); i++)
if (buf[i + 4] == page) if (buf[i + 4] == page)
goto found; 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 */ /* ran off the end of the buffer, give us benefit of doubt */
goto found; goto found;
/* The device claims it doesn't support the requested page */ /* The device claims it doesn't support the requested page */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment