linux-mips
[Top] [All Lists]

Re: [PATCH] small time list process error in prom_getenv()

To: Freddy Spierenburg <freddy@dusktilldawn.nl>
Subject: Re: [PATCH] small time list process error in prom_getenv()
From: Sergei Shtylylov <sshtylyov@ru.mvista.com>
Date: Mon, 27 Mar 2006 12:32:31 +0400
Cc: linux-mips@linux-mips.org
In-reply-to: <20060327074352.GC4781@dusktilldawn.nl>
Organization: MontaVista Software Inc.
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20060327074352.GC4781@dusktilldawn.nl>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; rv:1.7.2) Gecko/20040803
Hello.

Freddy Spierenburg wrote:

I found a small time bug in prom_getenv() for which I like to
share the fix with y'all.

prom_envp is an array with two elements per environment variable.
So for instance element 0 is memsize and element 1 is 0x08000000
for the environment variable memsize=0x08000000.

The code for prom_getenv() only skips one element when it's in
search for the next environment variable. It should of course
step two elements.

I found this error in two files and for both I include a patch to
fix the problem.

   I'm seeing such code in 3 files (arch/mips/ite-boards/generic/pmon_prom.c)
but that doesn't mean all of'em are incorrect. Alachemy code is though, since hose target use YAMON which passes environment args the described way. Though really, that code may be written this way on purpose -- like to fit both PMON's and YAMON's way of passing the environment...

Signed-off-by: Freddy Spierenburg <freddy@dusktilldawn.nl>

   NAK. 'val' field of 't_env_var' should be uncommented instead.

------------------------------------------------------------------------

diff -Naur linux.orig/arch/mips/philips/pnx8550/common/prom.c 
linux/arch/mips/philips/pnx8550/common/prom.c
--- linux.orig/arch/mips/philips/pnx8550/common/prom.c  2006-03-22 
15:25:58.000000000 +0000
+++ linux/arch/mips/philips/pnx8550/common/prom.c       2006-03-22 
15:25:23.000000000 +0000
@@ -70,7 +70,7 @@
                if(strncmp(envname, env->name, i) == 0) {
                        return(env->name + strlen(envname) + 1);
                }
-               env++;
+               env+=2;
        }
        return(NULL);
 }

   Not sure what loader the Philips target uses...

------------------------------------------------------------------------

diff -Naur linux.orig/arch/mips/au1000/common/prom.c 
linux/arch/mips/au1000/common/prom.c
--- linux.orig/arch/mips/au1000/common/prom.c   2006-03-22 15:11:09.000000000 
+0000
+++ linux/arch/mips/au1000/common/prom.c        2006-03-22 15:16:22.000000000 
+0000
@@ -97,7 +97,7 @@
                if(strncmp(envname, env->name, i) == 0) {
                        return(env->name + strlen(envname) + 1);

                        return env->val;

                }
-               env++;
+               env+=2;

   Should be left alone.

        }
        return(NULL);
 }

WBR, Sergei

<Prev in Thread] Current Thread [Next in Thread>