[PATCH] Minor numa memory code cleanup

Mike Kravetz kravetz at us.ibm.com
Tue Nov 29 15:14:57 EST 2005


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



More information about the Linuxppc64-dev mailing list