lkml.org 
[lkml]   [2010]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] avoiding the same resource to be inserted
On Mon, 16 Aug 2010 23:55:38 +0800
Huang Shijie <shijie8@gmail.com> wrote:

> 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

OK, we shouldn't do that.

> 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;

However, inserting the same thing twice _is_ a bug, and we shouldn't
silently accept it like this. We should tell the programmer!

But we can recover from the situation so let's not kill the box. How
does this look?

--- a/kernel/resource.c~kernel-resourcec-handle-reinsertion-of-an-already-inserted-resource
+++ a/kernel/resource.c
@@ -453,6 +453,8 @@ static struct resource * __insert_resour

if (first == parent)
return first;
+ if (WARN_ON(first == new)) /* duplicated insertion */
+ return first;

if ((first->start > new->start) || (first->end < new->end))
break;
_


\
 
 \ /
  Last update: 2010-08-25 01:51    [W:0.078 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site