]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: i2c: Add a missing memory allocaton check
authorSimon Glass <sjg@chromium.org>
Wed, 18 Feb 2015 21:10:28 +0000 (14:10 -0700)
committerSimon Glass <sjg@chromium.org>
Fri, 6 Mar 2015 02:13:35 +0000 (19:13 -0700)
This strdup() is missing a check. Add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
drivers/i2c/i2c-uclass.c

index a6991bf875df70a771d88a5d27c19fccd0d4af90..b890806a44ab35ef8b8c4319445967f7c9cbcff4 100644 (file)
@@ -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)