From: Hannes Reinecke <hare@suse.de>
To: Muthukumar R <muthu.lkml@gmail.com>
Cc: James Bottomley <jbottomley@parallels.com>,
Bart van Assche <bvanassche@acm.org>,
Christoph Hellwig <hch@infradead.org>,
linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH 2/5] scsi: Return VPD page length in scsi_vpd_inquiry()
Date: Thu, 13 Mar 2014 07:45:20 +0100 [thread overview]
Message-ID: <53215400.50907@suse.de> (raw)
In-Reply-To: <CAFR8ueeATrBwSMg_dmA2gY-Bt2D2+F8rR5zmDbN1ZC3Aw5bJMw@mail.gmail.com>
On 03/12/2014 10:14 PM, Muthukumar R wrote:
> On Mon, Mar 10, 2014 at 7:28 AM, Hannes Reinecke <hare@suse.de> wrote:
>> We should be returning the number of bytes of the
>> requested VPD page in scsi_vpd_inquiry.
>> This makes it easier for the caller to verify the
>> required space.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
>> ---
>> drivers/scsi/scsi.c | 17 ++++++++++-------
>> 1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
>> index d8afec8..ecaeff1 100644
>> --- a/drivers/scsi/scsi.c
>> +++ b/drivers/scsi/scsi.c
>> @@ -954,7 +954,7 @@ EXPORT_SYMBOL(scsi_track_queue_full);
>> * This is an internal helper function. You probably want to use
>> * scsi_get_vpd_page instead.
>> *
>> - * Returns 0 on success or a negative error number.
>> + * Returns size of the vpg page on success or a negative error number.
>> */
> Typo: ^^^
>
> Should be: vpd page
>
>
Ah. Correct.
>> static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
>> u8 page, unsigned len)
>> @@ -962,6 +962,9 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
>> int result;
>> unsigned char cmd[16];
>>
>> + if (len < 4)
>> + return -EINVAL;
>> +
>> cmd[0] = INQUIRY;
>> cmd[1] = 1; /* EVPD */
>> cmd[2] = page;
>> @@ -982,7 +985,7 @@ static int scsi_vpd_inquiry(struct scsi_device *sdev, unsigned char *buffer,
>> if (buffer[1] != page)
>> return -EIO;
>>
>> - return 0;
>> + return get_unaligned_be16(&buffer[2]) + 4;
>> }
>>
>> /**
>> @@ -1009,18 +1012,18 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
>>
>> /* Ask for all the pages supported by this device */
>> result = scsi_vpd_inquiry(sdev, buf, 0, buf_len);
>> - if (result)
>> + if (result < 4)
>> goto fail;
>
>
> You mean:
>
> if (result < 0)
> goto fail;
>
>
No. See above. The actual data starts at offset 4.
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-03-13 6:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-10 14:28 [PATCHv8 0/5] Display EVPD pages in sysfs Hannes Reinecke
2014-03-10 14:28 ` [PATCH 1/5] scsi_sysfs: Implement 'is_visible' callback Hannes Reinecke
2014-03-10 14:28 ` [PATCH 2/5] scsi: Return VPD page length in scsi_vpd_inquiry() Hannes Reinecke
2014-03-12 21:14 ` Muthukumar R
2014-03-12 21:43 ` Douglas Gilbert
2014-03-12 23:21 ` Muthukumar R
2014-03-13 6:45 ` Hannes Reinecke [this message]
2014-03-10 14:28 ` [PATCH 3/5] Add EVPD page 0x83 to sysfs Hannes Reinecke
2014-03-10 18:24 ` James Bottomley
2014-03-10 20:52 ` Hannes Reinecke
2014-03-11 4:14 ` James Bottomley
2014-03-11 11:56 ` Hannes Reinecke
2014-03-11 10:55 ` James Bottomley
2014-03-13 1:53 ` Martin K. Petersen
2014-03-13 3:31 ` James Bottomley
2014-03-12 8:03 ` hch
2014-03-10 14:28 ` [PATCH 4/5] Add EVPD page 0x80 " Hannes Reinecke
2014-03-10 14:28 ` [PATCH 5/5] ses: Use vpd information from scsi_device Hannes Reinecke
2014-03-10 18:20 ` James Bottomley
2014-03-10 20:44 ` Hannes Reinecke
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=53215400.50907@suse.de \
--to=hare@suse.de \
--cc=bvanassche@acm.org \
--cc=hch@infradead.org \
--cc=jbottomley@parallels.com \
--cc=linux-scsi@vger.kernel.org \
--cc=muthu.lkml@gmail.com \
/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.