Commit 38a7996c authored by Sachin Kamat's avatar Sachin Kamat Committed by Mauro Carvalho Chehab

[media] mem2mem_testdev: Use devm_kzalloc() in probe

devm_kzalloc() makes error handling and cleanup simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 26fdcf09
...@@ -1019,7 +1019,7 @@ static int m2mtest_probe(struct platform_device *pdev) ...@@ -1019,7 +1019,7 @@ static int m2mtest_probe(struct platform_device *pdev)
struct video_device *vfd; struct video_device *vfd;
int ret; int ret;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
...@@ -1027,7 +1027,7 @@ static int m2mtest_probe(struct platform_device *pdev) ...@@ -1027,7 +1027,7 @@ static int m2mtest_probe(struct platform_device *pdev)
ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
if (ret) if (ret)
goto free_dev; return ret;
atomic_set(&dev->num_inst, 0); atomic_set(&dev->num_inst, 0);
mutex_init(&dev->dev_mutex); mutex_init(&dev->dev_mutex);
...@@ -1073,8 +1073,6 @@ static int m2mtest_probe(struct platform_device *pdev) ...@@ -1073,8 +1073,6 @@ static int m2mtest_probe(struct platform_device *pdev)
video_device_release(vfd); video_device_release(vfd);
unreg_dev: unreg_dev:
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
free_dev:
kfree(dev);
return ret; return ret;
} }
...@@ -1089,7 +1087,6 @@ static int m2mtest_remove(struct platform_device *pdev) ...@@ -1089,7 +1087,6 @@ static int m2mtest_remove(struct platform_device *pdev)
del_timer_sync(&dev->timer); del_timer_sync(&dev->timer);
video_unregister_device(dev->vfd); video_unregister_device(dev->vfd);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment