diff options
author | Paolo Galtieri <pgaltieri@mvista.com> | 2005-10-11 11:29:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-10-11 12:46:54 -0400 |
commit | a0c111c631e7ab4abd68920debd44259160812ef (patch) | |
tree | bfcafa019ba2fb2bf38e5a07f9f5958b7ecb697f /arch/ppc | |
parent | 1bef40032992320dd25a266fc166bfb8fa3f2f59 (diff) |
[PATCH] ppc highmem fix
I've noticed that the calculations for seg_size and nr_segs in
__dma_sync_page_highmem() (arch/ppc/kernel/dma-mapping.c) are wrong. The
incorrect calculations can result in either an oops or a panic when running
fsck depending on the size of the partition.
The problem with the seg_size calculation is that it can result in a
negative number if size is offset > size. The problem with the nr_segs
caculation is returns the wrong number of segments, e.g. it returns 1 when
size is 200 and offset is 4095, when it should return 2 or more.
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/kernel/dma-mapping.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/ppc/kernel/dma-mapping.c b/arch/ppc/kernel/dma-mapping.c index b566d982806c..8edee806dae7 100644 --- a/arch/ppc/kernel/dma-mapping.c +++ b/arch/ppc/kernel/dma-mapping.c | |||
@@ -401,10 +401,10 @@ EXPORT_SYMBOL(__dma_sync); | |||
401 | static inline void __dma_sync_page_highmem(struct page *page, | 401 | static inline void __dma_sync_page_highmem(struct page *page, |
402 | unsigned long offset, size_t size, int direction) | 402 | unsigned long offset, size_t size, int direction) |
403 | { | 403 | { |
404 | size_t seg_size = min((size_t)PAGE_SIZE, size) - offset; | 404 | size_t seg_size = min((size_t)(PAGE_SIZE - offset), size); |
405 | size_t cur_size = seg_size; | 405 | size_t cur_size = seg_size; |
406 | unsigned long flags, start, seg_offset = offset; | 406 | unsigned long flags, start, seg_offset = offset; |
407 | int nr_segs = PAGE_ALIGN(size + (PAGE_SIZE - offset))/PAGE_SIZE; | 407 | int nr_segs = 1 + ((size - seg_size) + PAGE_SIZE - 1)/PAGE_SIZE; |
408 | int seg_nr = 0; | 408 | int seg_nr = 0; |
409 | 409 | ||
410 | local_irq_save(flags); | 410 | local_irq_save(flags); |