mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Leon Woestenberg" <leon.woestenberg@gmail.com>
To: "FUJITA Tomonori" <fujita.tomonori@lab.ntt.co.jp>,
	linux-kernel@vger.kernel.org,
	James.Bottomley@hansenpartnership.com, jens.axboe@oracle.com
Subject: scatterlist.c: bug in sg_next()?
Date: Sun, 28 Sep 2008 17:15:52 +0200	[thread overview]
Message-ID: <c384c5ea0809280815l63fab13fqf97a619598f0dd71@mail.gmail.com> (raw)

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,
-- 
Leon

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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-28 15:15 Leon Woestenberg [this message]
2008-09-28 15:28 ` Boaz Harrosh
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=c384c5ea0809280815l63fab13fqf97a619598f0dd71@mail.gmail.com \
    --to=leon.woestenberg@gmail.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jens.axboe@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®