From: Florian Zumbiehl <florz@gmx.de>
To: linux-kernel@vger.kernel.org
Subject: Wrong size calculation in __ioremap(), various platforms
Date: Thu, 14 Nov 2002 17:16:50 +0100 [thread overview]
Message-ID: <20021114161649.GA831@florz.dyndns.org> (raw)
Hi all,
in arch/*/mm/ioremap.c, __ioremap() of several platforms there seems to
be a minor mistake in the calculation of the page-aligned mapping size:
void * __ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags)
{
void * addr;
struct vm_struct * area;
unsigned long offset, last_addr;
/* Don't allow wraparound or zero size */
last_addr = phys_addr + size - 1;
if (!size || last_addr < phys_addr)
return NULL;
/* ... code which doesn't change last_addr ... */
size = PAGE_ALIGN(last_addr) - phys_addr;
/* ... */
}
For this calculation to work, PAGE_ALIGN(last_addr) would have to be
the address immediately after the last address to be mapped - if
last_addr is the first address of a page however, PAGE_ALIGN() of course
"returns" it unchanged.
So, the correct version IMO should look like this:
size = PAGE_ALIGN(last_addr + 1) - phys_addr;
(2.5.47?/)i386 even seems to be affected twice - bt_ioremap() contains the
same piece of code.
In the hope not to have overlooked something,
Florian
reply other threads:[~2002-11-14 16:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021114161649.GA831@florz.dyndns.org \
--to=florz@gmx.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®