[PATCH] kfifo: fix scatterlist usage

From: Ira W . Snyder
Date: Sat May 29 2010 - 15:02:47 EST


The current kfifo scatterlist implementation will not work with chained
scatterlists. It assumes that struct scatterlist arrays are allocated
contiguously, which is not the case when chained scatterlists (struct
sg_table) are in use.

Signed-off-by: Ira W. Snyder <kernel@xxxxxxxxxxxxx>
---
kernel/kfifo.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/kernel/kfifo.c b/kernel/kfifo.c
index 02192dd..bd4e083 100644
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -333,17 +333,16 @@ static int setup_sgl_buf(struct scatterlist *sgl, void *buf,
buf += PAGE_SIZE;
npage = virt_to_page(buf);
if (page_to_phys(page) != page_to_phys(npage) - l) {
- sgl->page_link = 0;
- sg_set_page(sgl++, page, l - off, off);
- if (++n == nents)
+ sg_set_page(sgl, page, l - off, off);
+ sgl = sg_next(sgl);
+ if (++n == nents || sgl == NULL)
return n;
page = npage;
len -= l - off;
l = off = 0;
}
}
- sgl->page_link = 0;
- sg_set_page(sgl++, page, len, off);
+ sg_set_page(sgl, page, len, off);
return n + 1;
}

--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/