media: vivid: fix error path
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 2 Sep 2020 06:54:01 +0000 (08:54 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 7 Sep 2020 14:02:51 +0000 (16:02 +0200)
If something fails after calling v4l2_device_register(),
it should call v4l2_device_put().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/test-drivers/vivid/vivid-core.c

index 54df7e0..4880999 100644 (file)
@@ -1698,10 +1698,8 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
                                       &has_tuner, &has_modulator,
                                       &ccs_cap, &ccs_out,
                                       in_type_counter, out_type_counter);
-       if (ret) {
-               kfree(dev);
-               return ret;
-       }
+       if (ret)
+               goto free_dev;
 
        vivid_set_capabilities(dev);