From: Simon Glass Date: Wed, 18 Feb 2015 21:10:28 +0000 (-0700) Subject: dm: i2c: Add a missing memory allocaton check X-Git-Tag: v2015.04-rc4~59^2~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5c2d23bf9e61e5f1c260fcb6633f70dea1a28e2f;p=oweals%2Fu-boot.git dm: i2c: Add a missing memory allocaton check This strdup() is missing a check. Add it. Signed-off-by: Simon Glass Acked-by: Heiko Schocher --- diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index a6991bf875..b890806a44 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)