mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] early_res: fix check in free_early_partial
@ 2010-06-04 21:10 Adam Lackorzynski
  2010-06-05  0:00 ` Yinghai Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Lackorzynski @ 2010-06-04 21:10 UTC (permalink / raw)
  To: linux-kernel, Yinghai Lu, Ingo Molnar, H. Peter Anvin

free_early_partial must check the returned region of find_overlapped_early()
whether it is a region at all. Otherwise the function will indefinitely
loop.

Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
---
 kernel/early_res.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/early_res.c b/kernel/early_res.c
index 31aa933..9afcb4c 100644
--- a/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -341,10 +341,11 @@ void __init free_early_partial(u64 start, u64 end)
 
 try_next:
 	i = find_overlapped_early(start, end);
-	if (i >= max_early_res)
+	r = &early_res[i];
+
+	if (i >= max_early_res || !r->end)
 		return;
 
-	r = &early_res[i];
 	/* hole ? */
 	if (r->end >= end && r->start <= start) {
 		drop_range_partial(i, start, end);
-- 
1.7.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] early_res: fix check in free_early_partial
  2010-06-04 21:10 [PATCH] early_res: fix check in free_early_partial Adam Lackorzynski
@ 2010-06-05  0:00 ` Yinghai Lu
  2010-06-06 11:32   ` Adam Lackorzynski
  0 siblings, 1 reply; 3+ messages in thread
From: Yinghai Lu @ 2010-06-05  0:00 UTC (permalink / raw)
  To: Adam Lackorzynski; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin

On Fri, Jun 4, 2010 at 2:10 PM, Adam Lackorzynski
<adam@os.inf.tu-dresden.de> wrote:
> free_early_partial must check the returned region of find_overlapped_early()
> whether it is a region at all. Otherwise the function will indefinitely
> loop.

do you have that hang really?

that stage we should not have blank slot in the middle.

Thanks

Yinghai Lu

>
> Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> ---
>  kernel/early_res.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/early_res.c b/kernel/early_res.c
> index 31aa933..9afcb4c 100644
> --- a/kernel/early_res.c
> +++ b/kernel/early_res.c
> @@ -341,10 +341,11 @@ void __init free_early_partial(u64 start, u64 end)
>
>  try_next:
>        i = find_overlapped_early(start, end);
> -       if (i >= max_early_res)
> +       r = &early_res[i];
> +
> +       if (i >= max_early_res || !r->end)
>                return;
>
> -       r = &early_res[i];
>        /* hole ? */
>        if (r->end >= end && r->start <= start) {
>                drop_range_partial(i, start, end);
> --
> 1.7.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] early_res: fix check in free_early_partial
  2010-06-05  0:00 ` Yinghai Lu
@ 2010-06-06 11:32   ` Adam Lackorzynski
  0 siblings, 0 replies; 3+ messages in thread
From: Adam Lackorzynski @ 2010-06-06 11:32 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin


On Fri Jun 04, 2010 at 17:00:02 -0700, Yinghai Lu wrote:
> On Fri, Jun 4, 2010 at 2:10 PM, Adam Lackorzynski
> <adam@os.inf.tu-dresden.de> wrote:
> > free_early_partial must check the returned region of find_overlapped_early()
> > whether it is a region at all. Otherwise the function will indefinitely
> > loop.
> 
> do you have that hang really?
> 
> that stage we should not have blank slot in the middle.

I did but I cannot manage to reproduce this now. I think this happens
when find_overlapped_early does not find a region, i.e. the given one
does not exist. Then it returns i == early_res_count which is smaller
than max_early_res (usually). Given that r->end == 0 this goes on
indefinitely. So the check would just be more robust with
i >= max_early_res || !r->end or i == early_res_count.

Adam

> > Signed-off-by: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
> > ---
> >  kernel/early_res.c |    5 +++--
> >  1 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/early_res.c b/kernel/early_res.c
> > index 31aa933..9afcb4c 100644
> > --- a/kernel/early_res.c
> > +++ b/kernel/early_res.c
> > @@ -341,10 +341,11 @@ void __init free_early_partial(u64 start, u64 end)
> >
> >  try_next:
> >        i = find_overlapped_early(start, end);
> > -       if (i >= max_early_res)
> > +       r = &early_res[i];
> > +
> > +       if (i >= max_early_res || !r->end)
> >                return;
> >
> > -       r = &early_res[i];
> >        /* hole ? */
> >        if (r->end >= end && r->start <= start) {
> >                drop_range_partial(i, start, end);
> > --
> > 1.7.1
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-06 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-04 21:10 [PATCH] early_res: fix check in free_early_partial Adam Lackorzynski
2010-06-05  0:00 ` Yinghai Lu
2010-06-06 11:32   ` Adam Lackorzynski

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®