public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: linux-scsi@vger.kernel.org, Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH] scsi: Add VPD helper
Date: Thu, 1 Jan 2009 06:38:18 -0700	[thread overview]
Message-ID: <20090101133818.GM2002@parisc-linux.org> (raw)
In-Reply-To: <495C8AA5.9010008@panasas.com>

On Thu, Jan 01, 2009 at 11:19:33AM +0200, Boaz Harrosh wrote:
> +	buffer[1] = -1;
> see below
> > +	/*
> > +	 * I'm not convinced we need to try quite this hard to get VPD, but
> > +	 * all the existing users tried this hard.
> > +	 */
> > +	result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer,
> > +				  len + 4, NULL, 30 * HZ, 3, NULL);
> > +	if (result)
> > +		return result;
> > +
> > +	/* Sanity check that we got the page back that we asked for */
> > +	if (buffer[1] != page)
> > +		return -EIO;
> 
> Maybe it's just me but, if you are going to if() on a buffer byte, then you need
> to make sure its initial value. Or at least document the need for a -1 at
> buffer[1]

buffer[] is an array of unsigned char, so -1 is 255.  We could be asking
for page 0xff, so your initialisation doesn't help reject bogus data.

Your concern here, presumably, is that the device might transfer less than
two bytes, and not return an error.  I think this is quite unlikely --
and in any case, such a misbehaving device is really no different from a
device which transfers complete garbage.

I suppose we could pass a 'resid' to scsi_execute_req and check that at
least four bytes was transferred.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

  reply	other threads:[~2009-01-01 13:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-31 18:12 [PATCH] scsi: Add VPD helper Matthew Wilcox
2008-12-31 18:12 ` [PATCH] ses: Use new scsi " Matthew Wilcox
2008-12-31 18:59   ` James Bottomley
2008-12-31 19:11     ` Matthew Wilcox
2009-01-01  9:19 ` [PATCH] scsi: Add " Boaz Harrosh
2009-01-01 13:38   ` Matthew Wilcox [this message]
2009-01-10 18:53 ` James Bottomley

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=20090101133818.GM2002@parisc-linux.org \
    --to=matthew@wil.cx \
    --cc=bharrosh@panasas.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=willy@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox