Skip to content

Commit

Permalink
media: aspeed-video: Fix memory leaks in aspeed_video_probe
Browse files Browse the repository at this point in the history
In the implementation of aspeed_video_probe() the allocated memory for
video should be released if either devm_ioremap_resource()
or aspeed_video_init() or aspeed_video_setup_video() fails. Replace
kzalloc() with devm_kzalloc to avoid explicit release for video.

Fixes: d2b4387 ("media: platform: Add Aspeed Video Engine driver")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
Reviewed-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
  • Loading branch information
Navid Emamdoost authored and Mauro Carvalho Chehab committed Nov 10, 2019
1 parent 99cf8a7 commit c3df30a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/media/platform/aspeed-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,8 @@ static int aspeed_video_probe(struct platform_device *pdev)
{
int rc;
struct resource *res;
struct aspeed_video *video = kzalloc(sizeof(*video), GFP_KERNEL);
struct aspeed_video *video =
devm_kzalloc(&pdev->dev, sizeof(*video), GFP_KERNEL);

if (!video)
return -ENOMEM;
Expand Down

0 comments on commit c3df30a

Please sign in to comment.