Skip to content

Commit

Permalink
[media] mem2mem_testdev: Use devm_kzalloc() in probe
Browse files Browse the repository at this point in the history
devm_kzalloc() makes error handling and cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Sachin Kamat authored and Mauro Carvalho Chehab committed Oct 6, 2012
1 parent 26fdcf0 commit 38a7996
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/media/platform/mem2mem_testdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,15 +1019,15 @@ static int m2mtest_probe(struct platform_device *pdev)
struct video_device *vfd;
int ret;

dev = kzalloc(sizeof(*dev), GFP_KERNEL);
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;

spin_lock_init(&dev->irqlock);

ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
if (ret)
goto free_dev;
return ret;

atomic_set(&dev->num_inst, 0);
mutex_init(&dev->dev_mutex);
Expand Down Expand Up @@ -1073,8 +1073,6 @@ static int m2mtest_probe(struct platform_device *pdev)
video_device_release(vfd);
unreg_dev:
v4l2_device_unregister(&dev->v4l2_dev);
free_dev:
kfree(dev);

return ret;
}
Expand All @@ -1089,7 +1087,6 @@ static int m2mtest_remove(struct platform_device *pdev)
del_timer_sync(&dev->timer);
video_unregister_device(dev->vfd);
v4l2_device_unregister(&dev->v4l2_dev);
kfree(dev);

return 0;
}
Expand Down

0 comments on commit 38a7996

Please sign in to comment.