mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com
Cc: linux-arch@vger.kernel.org, tony.luck@intel.com,
	linux@arm.linux.org.uk, arnd@arndb.de, benh@kernel.crashing.org,
	mcgrof@suse.com, x86@kernel.org, linux-kernel@vger.kernel.org,
	ralf@linux-mips.org, Mike Travis <travis@sgi.com>,
	geert@linux-m68k.org, ross.zwisler@linux.intel.com,
	toshi.kani@hp.com, Andrew Morton <akpm@linux-foundation.org>,
	hch@lst.de, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/10] mm: Fix bugs in region_is_ram()
Date: Sun, 19 Jul 2015 20:17:49 -0400	[thread overview]
Message-ID: <20150720001749.30857.97562.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <20150720001614.30857.89063.stgit@dwillia2-desk3.amr.corp.intel.com>

From: Toshi Kani <toshi.kani@hp.com>

region_is_ram() looks up the iomem_resource table to check if
a target range is in RAM.  However, it always returns with -1
due to invalid range checks.  It always breaks the loop at the
first entry of the table.

Another issue is that it compares p->flags and flags, but it
always fails.  The flags is declared as int, which makes it as
a negative value with IORESOURCE_BUSY (0x80000000) set while
p->flags is unsigned long.

Fix the range check and flags so that region_is_ram() works as
advertised.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Cc: Mike Travis <travis@sgi.com>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 kernel/resource.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 90552aab5f2d..fed052a1bc9f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -504,13 +504,13 @@ int region_is_ram(resource_size_t start, unsigned long size)
 {
 	struct resource *p;
 	resource_size_t end = start + size - 1;
-	int flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+	unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 	const char *name = "System RAM";
 	int ret = -1;
 
 	read_lock(&resource_lock);
 	for (p = iomem_resource.child; p ; p = p->sibling) {
-		if (end < p->start)
+		if (p->end < start)
 			continue;
 
 		if (p->start <= start && end <= p->end) {
@@ -521,7 +521,7 @@ int region_is_ram(resource_size_t start, unsigned long size)
 				ret = 1;
 			break;
 		}
-		if (p->end < start)
+		if (end < p->start)
 			break;	/* not found */
 	}
 	read_unlock(&resource_lock);


  parent reply	other threads:[~2015-07-20  0:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20  0:17 [PATCH 00/10] unify ioremap definitions and introduce memremap Dan Williams
2015-07-20  0:17 ` [PATCH 01/10] mm, x86: Fix warning in ioremap RAM check Dan Williams
2015-07-20  0:17 ` [PATCH 02/10] mm, x86: Remove region_is_ram() call from ioremap Dan Williams
2015-07-20  0:17 ` Dan Williams [this message]
2015-07-20  0:17 ` [PATCH 04/10] arch, drivers: don't include <asm/io.h> directly, use <linux/io.h> instead Dan Williams
2015-07-20  0:18 ` [PATCH 05/10] arch: unify ioremap prototypes and macro aliases Dan Williams
2015-07-21 13:34   ` Christoph Hellwig
2015-07-21 16:08     ` Dan Williams
2015-07-20  0:18 ` [PATCH 06/10] cleanup IORESOURCE_CACHEABLE vs ioremap() Dan Williams
2015-07-20  0:18 ` [PATCH 07/10] devm: fix ioremap_cache() usage Dan Williams
2015-07-20  0:18 ` [PATCH 08/10] arch: introduce strict_ioremap Dan Williams
2015-07-21 13:30   ` Christoph Hellwig
2015-07-21 16:11     ` Dan Williams
2015-07-20  0:18 ` [PATCH 09/10] arch: introduce memremap() Dan Williams
2015-07-20 12:00   ` Mark Rutland
2015-07-20 14:39     ` Dan Williams
2015-07-20 15:56       ` Mark Rutland
2015-07-21 23:58   ` Luis R. Rodriguez
2015-07-22  4:04     ` Dan Williams
2015-07-22 22:55       ` Luis R. Rodriguez
2015-07-22 23:15         ` Dan Williams
2015-07-23  0:55           ` Luis R. Rodriguez
2015-07-23  1:02             ` Dan Williams
2015-07-20  0:18 ` [PATCH 10/10] pmem: convert to generic memremap Dan Williams

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=20150720001749.30857.97562.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=geert@linux-m68k.org \
    --cc=hch@lst.de \
    --cc=hpa@zytor.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mcgrof@suse.com \
    --cc=mingo@kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=toshi.kani@hp.com \
    --cc=travis@sgi.com \
    --cc=x86@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®