[Skiboot] [PATCH 3/3] [Device] Verify zalloc returned valid pointer

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Thu Jun 18 15:38:07 AEST 2015


On 06/17/2015 01:53 PM, Ananth N Mavinakayanahalli wrote:
> Else, we are dereferencing NULL
> 
> Signed-off-by: Ananth N Mavinakayanahalli <ananth at in.ibm.com>

Looks good.

Reviewed-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>

-Vasant


> ---
>  core/device.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/core/device.c b/core/device.c
> index 09f76d7..ba427de 100644
> --- a/core/device.c
> +++ b/core/device.c
> @@ -348,6 +348,9 @@ struct dt_property *dt_add_property_nstr(struct dt_node *node,
>  	struct dt_property *p;
>  	char *tmp = zalloc(vlen + 1);
>  
> +	if (!tmp)
> +		return NULL;
> +
>  	strncpy(tmp, value, vlen);
>  	p = dt_add_property(node, name, tmp, strlen(tmp)+1);
>  	free(tmp);
> 
> _______________________________________________
> Skiboot mailing list
> Skiboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
> 



More information about the Skiboot mailing list