Skip to contentSkip to conversation

kernel/resource.c: use signed length comparing instead of position comparing

PATCH New Chen Gang 1 participant 1 message Nov 4, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Chen Gang

author
#1 lore raw

PATCH v2 1/1 kernel/resource.c: use signed length comparing instead of position comparing

Sorry, forgot to cc linux-kernel.

-------- Original Message --------
Subject: [PATCH v2] kernel/resource.c: use signed length comparing instead of position comparing
Date: Mon, 04 Nov 2013 11:05:30 +0800
From: Chen Gang <[email protected]>
To: Toshi Kani <[email protected]>, "[email protected]" <[email protected]>, [email protected], [email protected]
CC: Andrew Morton <[email protected]>

Theoretically, "addr + size" may be overflow (e.g. equal 0), so use signed length comparing instead of position comparing.

---
 kernel/resource.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/resource.c +1 -1
index 3f285dc..0783733 100644
@@ -1335,7 +1335,7 @@ int iomem_is_exclusive(u64 addr)
 		 * We can probably skip the resources without
 		 * IORESOURCE_IO attribute?
 		 */
-		if (p->start >= addr + size)
+		if ((s64)(p->start - addr) >= size)
 			break;
 		if (p->end < addr)
 			continue;
Signature · 1 line
1.7.7.6