Commit d78a3eda authored by Stefani Seibold's avatar Stefani Seibold Committed by Linus Torvalds

kernel/kfifo.c: add handling of chained scatterlists

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: default avatarStefani Seibold <stefani@seibold.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5af568cb
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -333,17 +333,16 @@ static int setup_sgl_buf(struct scatterlist *sgl, void *buf, ...@@ -333,17 +333,16 @@ static int setup_sgl_buf(struct scatterlist *sgl, void *buf,
buf += PAGE_SIZE; buf += PAGE_SIZE;
npage = virt_to_page(buf); npage = virt_to_page(buf);
if (page_to_phys(page) != page_to_phys(npage) - l) { if (page_to_phys(page) != page_to_phys(npage) - l) {
sgl->page_link = 0; sg_set_page(sgl, page, l - off, off);
sg_set_page(sgl++, page, l - off, off); sgl = sg_next(sgl);
if (++n == nents) if (++n == nents || sgl == NULL)
return n; return n;
page = npage; page = npage;
len -= l - off; len -= l - off;
l = off = 0; l = off = 0;
} }
} }
sgl->page_link = 0; sg_set_page(sgl, page, len, off);
sg_set_page(sgl++, page, len, off);
return n + 1; return n + 1;
} }
...@@ -363,7 +362,7 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, ...@@ -363,7 +362,7 @@ static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl,
} }
l = min(len, size - off); l = min(len, size - off);
n = setup_sgl_buf(sgl, fifo->data + off, nents, l); n = setup_sgl_buf(sgl, fifo->data + off, nents, l);
n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l); n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l);
if (n) if (n)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment