[U-Boot] [PATCH 01/22] dm: i2c: Add a missing memory allocaton check

Heiko Schocher hs at denx.de
Thu Feb 19 08:41:47 CET 2015


Hello Simon,

Am 18.02.2015 22:10, schrieb Simon Glass:
> This strdup() is missing a check. Add it.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>   drivers/i2c/i2c-uclass.c | 2 ++
>   1 file changed, 2 insertions(+)

Good catch, Thanks!

Acked-by: Heiko Schocher <hs at denx.de>

bye,
Heiko
>
> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
> index a6991bf..b890806 100644
> --- a/drivers/i2c/i2c-uclass.c
> +++ b/drivers/i2c/i2c-uclass.c
> @@ -230,6 +230,8 @@ static int i2c_bind_driver(struct udevice *bus, uint chip_addr, uint offset_len,
>
>   	snprintf(name, sizeof(name), "generic_%x", chip_addr);
>   	str = strdup(name);
> +	if (!str)
> +		return -ENOMEM;
>   	ret = device_bind_driver(bus, "i2c_generic_chip_drv", str, &dev);
>   	debug("%s:  device_bind_driver: ret=%d\n", __func__, ret);
>   	if (ret)
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list