Is high_memory check in omap2.c for OneNAND is sufficient?

Singh, Vimal vimalsingh at ti.com
Tue Mar 24 11:20:11 EDT 2009


Hi,

There is check for 'high_memory' in 'drivers/mtd/onenand/omap2.c', always before doing 'dma_map_single'.
Snippet:
----------------------
        if (buf >= high_memory) {
                struct page *p1;
----------------------
This check seems not sufficient. There should be a check for upper boundary too.
Thinking scenario when 'buf' is less than 'high_memory', but somewhere near to it, and 'count' is big enough to beyond 'high_memory'.
Then again, function 'dma_cache_maint' will report bug.

Snippet:
--------------
void dma_cache_maint(const void *start, size_t size, int direction)
{
        const void *end = start + size;

        BUG_ON(!virt_addr_valid(start) || !virt_addr_valid(end - 1));
-------------

Should we replace "if (buf >= high_memory)" with "if (buf >= high_memory || (buf + count -1) >= high_memory)"...?

---
vimal


More information about the linux-mtd mailing list