lkml.org 
[lkml]   [2008]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectscatterlist.c: bug in sg_next()?
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


\
 
 \ /
  Last update: 2008-09-28 17:19    [W:0.212 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site