All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boaz Harrosh <bharrosh@panasas.com>
To: Leon Woestenberg <leon.woestenberg@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
	linux-kernel@vger.kernel.org,
	James.Bottomley@hansenpartnership.com, jens.axboe@oracle.com
Subject: Re: scatterlist.c: bug in sg_next()?
Date: Sun, 28 Sep 2008 18:28:05 +0300	[thread overview]
Message-ID: <48DFA285.1010701@panasas.com> (raw)
In-Reply-To: <c384c5ea0809280815l63fab13fqf97a619598f0dd71@mail.gmail.com>

Leon Woestenberg wrote:
> Hello,
> 
> I was code-inspecting 2.6.27-r7 through git web, when I came across this:
> 
> In sg_next(), after following a chain_ptr, a few more checks should be
> performed.
> The rare case exists that the first entry in the chained list is a
> last marker, in case NULL must be returned.
> 
> Can someone confirm and cook a patch?
> 
> struct scatterlist *sg_next(struct scatterlist *sg)
> {
>   if (sg_is_last(sg))
>     return NULL;
>   sg++;
>   if (unlikely(sg_is_chain(sg))) {
>      sg = sg_chain_ptr(sg);
> +#ifdef CONFIG_DEBUG_SG
> + BUG_ON(sg->sg_magic != SG_MAGIC);
> +#endif
> +   if (sg_is_last(sg))
> +     return NULL;
>   }
>   return sg;
> }
> 
> Signed-off-by: Leon Woestenberg <leon@sidebranch.com>
> 
> Regards,

No! the last marker is set on a valid sg entry. Only it's next
is no longer valid. So the check at the top is for the Next-sg
not the passed-in-sg. What you thought of is a NULL terminating
sg-list. The end marker is so to save the extra NULL entry.

Boaz


  reply	other threads:[~2008-09-28 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-28 15:15 scatterlist.c: bug in sg_next()? Leon Woestenberg
2008-09-28 15:28 ` Boaz Harrosh [this message]
2008-09-28 15:51   ` Leon Woestenberg

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=48DFA285.1010701@panasas.com \
    --to=bharrosh@panasas.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jens.axboe@oracle.com \
    --cc=leon.woestenberg@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.