summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-02-18 14:10:28 -0700
committerSimon Glass <sjg@chromium.org>2015-03-05 19:13:35 -0700
commit5c2d23bf9e61e5f1c260fcb6633f70dea1a28e2f (patch)
tree8da33c440b7ce3ec1ee91bd7d4f99e138cafe07a /drivers/i2c
parent694cc87b76b1063a2a7a8bd1809e990df0a469f8 (diff)
downloadu-boot-imx-5c2d23bf9e61e5f1c260fcb6633f70dea1a28e2f.zip
u-boot-imx-5c2d23bf9e61e5f1c260fcb6633f70dea1a28e2f.tar.gz
u-boot-imx-5c2d23bf9e61e5f1c260fcb6633f70dea1a28e2f.tar.bz2
dm: i2c: Add a missing memory allocaton check
This strdup() is missing a check. Add it. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-uclass.c2
1 files changed, 2 insertions, 0 deletions
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)