From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: roel kluin <roel.kluin@gmail.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [SCSI] libsas: fix test for negative unsigned and typos
Date: Wed, 03 Dec 2008 10:19:01 -0600 [thread overview]
Message-ID: <1228321141.5551.18.camel@localhost.localdomain> (raw)
In-Reply-To: <49316E4C.7070808@gmail.com>
On Sat, 2008-11-29 at 11:31 -0500, roel kluin wrote:
> unsigned req->data_len cannot be negative, and fix typo
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> I am not sure whether this is what was intended, please review.
I think it was. The fix looks like we need it. However:
> diff --git a/drivers/scsi/libsas/sas_host_smp.c b/drivers/scsi/libsas/sas_host_smp.c
> index 16f9312..6eb0779 100644
> --- a/drivers/scsi/libsas/sas_host_smp.c
> +++ b/drivers/scsi/libsas/sas_host_smp.c
> @@ -199,12 +199,12 @@ int sas_smp_host_handler(struct Scsi_Host *shost, struct request *req,
> break;
>
> case SMP_DISCOVER:
> - req->data_len =- 16;
> - if (req->data_len < 0) {
> + if (req->data_len < 15) {
> req->data_len = 0;
> error = -EINVAL;
> goto out;
> }
What I don't like about this code is the magic numbers for lengths.
This patch now doubles them (and makes them even more magic by having <
n-1). How about fixing it like this instead:
if ((int)req->data_len < 0) {
...
That way the signed comparison just works if there was a negative
overflow?
Thanks,
James
prev parent reply other threads:[~2008-12-03 16:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-29 16:31 [PATCH] [SCSI] libsas: fix test for negative unsigned and typos roel kluin
2008-12-03 16:19 ` James Bottomley [this message]
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=1228321141.5551.18.camel@localhost.localdomain \
--to=james.bottomley@hansenpartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=roel.kluin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox