[media] coda: check kasprintf return value in coda_open
authorPeter Seiderer <ps.report@gmx.net>
Tue, 24 Mar 2015 17:30:47 +0000 (14:30 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Fri, 10 Apr 2015 13:03:52 +0000 (10:03 -0300)
kasprintf might fail if free memory is low.

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/platform/coda/coda-common.c

index ddbed9b4ae410c079ade954dfd78773c0f79a32e..c82ce562d95a0c868e18b14c50b26224976ffe74 100644 (file)
@@ -1628,6 +1628,11 @@ static int coda_open(struct file *file)
        set_bit(idx, &dev->instance_mask);
 
        name = kasprintf(GFP_KERNEL, "context%d", idx);
+       if (!name) {
+               ret = -ENOMEM;
+               goto err_coda_name_init;
+       }
+
        ctx->debugfs_entry = debugfs_create_dir(name, dev->debugfs_root);
        kfree(name);
 
@@ -1742,6 +1747,7 @@ err_pm_get:
        v4l2_fh_del(&ctx->fh);
        v4l2_fh_exit(&ctx->fh);
        clear_bit(ctx->idx, &dev->instance_mask);
+err_coda_name_init:
 err_coda_max:
        kfree(ctx);
        return ret;