[PATCH] avoiding the same resource to be inserted

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Huang Shijie
Date: Monday, August 16, 2010 - 8:55 am

If the same resource is inserted to the resource tree
(maybe not on purpose), a dead loop will be created. In this situation,
The kernel does not report any warning or error	:(

  The command below will show a endless print.
  #cat /proc/iomem

  So, adding the check for the same resource is needed for the stability
and reliability of the kernel.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 kernel/resource.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/resource.c b/kernel/resource.c
index 7b36976..60daab4 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -451,7 +451,7 @@ static struct resource * __insert_resource(struct resource *parent, struct resou
 		if (!first)
 			return first;
 
-		if (first == parent)
+		if (first == parent || first == new)
 			return first;
 
 		if ((first->start > new->start) || (first->end < new->end))
-- 
1.6.6.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] avoiding the same resource to be inserted, Huang Shijie, (Mon Aug 16, 8:55 am)
Re: [PATCH] avoiding the same resource to be inserted, Andrew Morton, (Tue Aug 24, 4:46 pm)
Re: [PATCH] avoiding the same resource to be inserted, Huang Shijie, (Tue Aug 24, 9:31 pm)
Re: [PATCH] avoiding the same resource to be inserted, Huang Shijie, (Tue Aug 24, 10:03 pm)
Re: [PATCH] avoiding the same resource to be inserted, Andrew Morton, (Tue Aug 24, 11:41 pm)
Re: [PATCH] avoiding the same resource to be inserted, Huang Shijie, (Wed Aug 25, 12:01 am)
Re: [PATCH] avoiding the same resource to be inserted, Bjorn Helgaas, (Wed Aug 25, 8:17 am)