linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* do_mmap_pgoff issue...
@ 2006-04-27 13:59 Gerhard Jaeger
  2006-04-27 22:47 ` Paul Mackerras
  0 siblings, 1 reply; 2+ messages in thread
From: Gerhard Jaeger @ 2006-04-27 13:59 UTC (permalink / raw)
  To: linuxppc-dev

Hi list,

while trying to mmap some flash area on my mpc8541 CDS board, 
I noticed that the overflow case is probably not correctly handled 
within function do_mmap_pgoff in linux/mm/mmap.c

The facts:
- mmap the last page @ 0xFFFFF000, len 4K
- result: mmap says EOVERFLOW...
- the function that failed was do_mmap_pgoff()

Here's the pice of code

/* offset overflow? */
if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
    return -EOVERFLOW;

It's quite clear why it fails in my case:
pgoff + (len >> PAGE_SHIFT) will be 0

I fixed that by inserting the following, to handle that special case:

if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) {
    if ((pgoff + (len >> PAGE_SHIFT)) != 0 )
        return -EOVERFLOW;
}

My question is - is that behaviour a bug or a feature? In fact it's
an off-by-one issue, but I could not believe, that nobody else ever
had problems with that.

TIA for enlighten me
Gerhard

-- 
Gerhard Jaeger <gjaeger@sysgo.com>            
SYSGO AG                      Embedded and Real-Time Software
www.sysgo.com | www.elinos.com | www.pikeos.com | www.osek.de 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-27 22:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-27 13:59 do_mmap_pgoff issue Gerhard Jaeger
2006-04-27 22:47 ` Paul Mackerras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).