blob: 3b8eee013bbb59bdf072a9cd3fe39280f0d22eb1 [file] [log] [blame]
From 1cfb9f4fdbd47ebdf11d200264dd9e6d7f1c86ee Mon Sep 17 00:00:00 2001
From: Navid Emamdoost <>
Date: Sun, 10 Nov 2019 07:23:38 +0100
Subject: [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
commit c3df30a01da4955e04fa068c503cd784b31dad92 upstream.
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: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
Signed-off-by: Navid Emamdoost <>
Reviewed-by: Jae Hyun Yoo <>
Reviewed-by: Eddie James <>
Signed-off-by: Hans Verkuil <>
Signed-off-by: Mauro Carvalho Chehab <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index 3c6c15d5d6be..3573270c8bbd 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -1648,7 +1648,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;