[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linuxppc64-dev
Subject:    [PATCH] Minor numa memory code cleanup
From:       kravetz () us ! ibm ! com (Mike Kravetz)
Date:       2005-11-29 4:14:57
Message-ID: 20051129041457.GA20928 () w-mikek ! beaverton ! ibm ! com
[Download RAW message or body]

On Mon, Nov 28, 2005 at 07:25:31PM -0600, Nathan Lynch wrote:
> Mike Kravetz wrote:
> 
> > -static int __init get_mem_size_cells(void)
> > -{
> > -	struct device_node *memory = NULL;
> > -	int rc;
> > -
> > -	memory = of_find_node_by_type(memory, "memory");
> > -	if (!memory)
> > -		return 0; /* it won't matter */
> > -	rc = prom_n_size_cells(memory);
> > -	return rc;
> > +	if (memory) {
> > +		*n_addr_cells = prom_n_addr_cells(memory);
> > +		*n_size_cells = prom_n_size_cells(memory);
> > +		of_node_put(memory);
> > +	}
> > +	/* if (!memory) we are in trouble, let other code error out */
> >  }
> 
> 
> Except the caller below doesn't sanity-check the values returned and
> we'll have some mysterious crash or something later in boot.

OK - I'll add something like a panic if we ever hit this situation.
The current version of the code returns zero for the values in this
case.  But, the returned values would never be used because their use
is within the 'while ((memory ... != NULL) {' loop which will never
be executed.

-- 
Mike Kravetz                                  kravetz at us.ibm.com
IBM Peace, Love and Linux Technology Center


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic