[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] [RFC!] [PATCH] microblaze: fix bug in error handling



Hi Ilpo,

I forward this patch to PowerPC mailing list.
They are autors of prom_parse.c file.
We wanted to move prom_parse.c file to any generic location (maybe drivers/of)
and they have very similar code (I have there some cleanup) and if this bug is there
they remove it.

Thanks,
Michal

Ilpo Järvinen wrote:
> While some version of the patches were on the lkml I read
> some part of the code briefly through but my feedback got
> stuck into postponed emails, so here's one correctness
> related issue I might have found (the rest were just
> cosmetic things).
> 
> I'm not sure if the latter return needs the of_node_put or not
> but it seems more likely than not.
> 
> Not even compile tested.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxx>
> ---
>  arch/microblaze/kernel/prom_parse.c |   11 +++++++----
>  1 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/microblaze/kernel/prom_parse.c b/arch/microblaze/kernel/prom_parse.c
> index ae0352e..d1174bc 100644
> --- a/arch/microblaze/kernel/prom_parse.c
> +++ b/arch/microblaze/kernel/prom_parse.c
> @@ -927,20 +927,23 @@ int of_irq_map_one(struct device_node *device,
>  	/* Get size of interrupt specifier */
>  	tmp = of_get_property(p, "#interrupt-cells", NULL);
>  	if (tmp == NULL) {
> -		of_node_put(p);
> -		return -EINVAL;
> +		res = -EINVAL;
> +		goto out;
>  	}
>  	intsize = *tmp;
>  
>  	pr_debug(" intsize=%d intlen=%d\n", intsize, intlen);
>  
>  	/* Check index */
> -	if ((index + 1) * intsize > intlen)
> -		return -EINVAL;
> +	if ((index + 1) * intsize > intlen) {
> +		res = -EINVAL;
> +		goto out;
> +	}
>  
>  	/* Get new specifier and map it */
>  	res = of_irq_map_raw(p, intspec + index * intsize, intsize,
>  				addr, out_irq);
> +out:
>  	of_node_put(p);
>  	return res;
>  }

-- 
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/