]> git.sur5r.net Git - u-boot/commitdiff
dm: blk: Free the block device name when unbound
authorSimon Glass <sjg@chromium.org>
Sun, 1 May 2016 19:52:24 +0000 (13:52 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 17 May 2016 15:54:43 +0000 (09:54 -0600)
Mark the device name as allocated so that it will be freed correctly when the
device is unbound.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/block/blk-uclass.c

index f67f9b9d5524cc7c01d5063ff06cb472a75868c0..a37239ee504c7ecf53d7a3b0b1b503bcac866564 100644 (file)
@@ -468,14 +468,22 @@ int blk_create_devicef(struct udevice *parent, const char *drv_name,
                       lbaint_t size, struct udevice **devp)
 {
        char dev_name[30], *str;
+       int ret;
 
        snprintf(dev_name, sizeof(dev_name), "%s.%s", parent->name, name);
        str = strdup(dev_name);
        if (!str)
                return -ENOMEM;
 
-       return blk_create_device(parent, drv_name, str, if_type, devnum,
-                                blksz, size, devp);
+       ret = blk_create_device(parent, drv_name, str, if_type, devnum,
+                               blksz, size, devp);
+       if (ret) {
+               free(str);
+               return ret;
+       }
+       device_set_name_alloced(*devp);
+
+       return ret;
 }
 
 int blk_unbind_all(int if_type)