linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
@ 2019-10-26  4:25 Navid Emamdoost
  2019-10-27  6:55 ` Markus Elfring
  2019-10-28 16:27 ` Jae Hyun Yoo
  0 siblings, 2 replies; 11+ messages in thread
From: Navid Emamdoost @ 2019-10-26  4:25 UTC (permalink / raw)
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-media, linux-kernel, emamd001, Joel Stanley, smccaman,
	Mauro Carvalho Chehab, linux-arm-kernel, Navid Emamdoost

In the implementation of aspeed_video_probe() the allocated memory for
video should be released in case of failure. Release video if either
devm_ioremap_resource() or aspeed_video_init() or
aspeed_video_setup_video() fails.

Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/media/platform/aspeed-video.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index eb12f3793062..8c473356132d 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -1663,18 +1663,24 @@ static int aspeed_video_probe(struct platform_device *pdev)
 
 	video->base = devm_ioremap_resource(video->dev, res);
 
-	if (IS_ERR(video->base))
-		return PTR_ERR(video->base);
+	if (IS_ERR(video->base)) {
+		rc = PTR_ERR(video->base);
+		goto free_video;
+	}
 
 	rc = aspeed_video_init(video);
 	if (rc)
-		return rc;
+		goto free_video;
 
 	rc = aspeed_video_setup_video(video);
 	if (rc)
-		return rc;
+		goto free_video;
 
 	return 0;
+
+free_video:
+	kfree(video);
+	return rc;
 }
 
 static int aspeed_video_remove(struct platform_device *pdev)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-26  4:25 [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe Navid Emamdoost
@ 2019-10-27  6:55 ` Markus Elfring
  2019-10-28 16:27 ` Jae Hyun Yoo
  1 sibling, 0 replies; 11+ messages in thread
From: Markus Elfring @ 2019-10-27  6:55 UTC (permalink / raw)
  To: Navid Emamdoost, linux-arm-kernel, linux-aspeed, linux-media, openbmc
  Cc: kernel-janitors, Andrew Jeffery, Kangjie Lu, Eddie James, LKML,
	Navid Emamdoost, Joel Stanley, Stephen McCamant,
	Mauro Carvalho Chehab

…
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1663,18 +1663,24 @@ static int aspeed_video_probe(struct platform_device *pdev)
> +free_video:
> +	kfree(video);
…

I am curious if there is a need for such a memory release at another place.
How do you think about to add this function call also to the implementation
of the function “aspeed_video_remove”?

Regards,
Markus

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-26  4:25 [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe Navid Emamdoost
  2019-10-27  6:55 ` Markus Elfring
@ 2019-10-28 16:27 ` Jae Hyun Yoo
  2019-10-28 16:30   ` Navid Emamdoost
  2019-10-28 16:58   ` [PATCH v2] " Navid Emamdoost
  1 sibling, 2 replies; 11+ messages in thread
From: Jae Hyun Yoo @ 2019-10-28 16:27 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-kernel, emamd001, smccaman, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-media

Hi Navid,

On 10/25/2019 9:25 PM, Navid Emamdoost wrote:
> In the implementation of aspeed_video_probe() the allocated memory for
> video should be released in case of failure. Release video if either
> devm_ioremap_resource() or aspeed_video_init() or
> aspeed_video_setup_video() fails.
> 
> Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>   drivers/media/platform/aspeed-video.c | 14 ++++++++++----
>   1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..8c473356132d 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1663,18 +1663,24 @@ static int aspeed_video_probe(struct platform_device *pdev)
>   
>   	video->base = devm_ioremap_resource(video->dev, res);
>   
> -	if (IS_ERR(video->base))
> -		return PTR_ERR(video->base);
> +	if (IS_ERR(video->base)) {
> +		rc = PTR_ERR(video->base);
> +		goto free_video;
> +	}
>   
>   	rc = aspeed_video_init(video);
>   	if (rc)
> -		return rc;
> +		goto free_video;
>   
>   	rc = aspeed_video_setup_video(video);
>   	if (rc)
> -		return rc;
> +		goto free_video;
>   
>   	return 0;
> +
> +free_video:
> +	kfree(video);
> +	return rc;
>   }
>   
>   static int aspeed_video_remove(struct platform_device *pdev)
> 

Can we simply change kzalloc in aspeed_video_probe with devm_kzalloc
so that we don't need to take care of freeing of video? I think it would
be more simpler.

Cheers,

Jae

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 16:27 ` Jae Hyun Yoo
@ 2019-10-28 16:30   ` Navid Emamdoost
  2019-10-28 16:58   ` [PATCH v2] " Navid Emamdoost
  1 sibling, 0 replies; 11+ messages in thread
From: Navid Emamdoost @ 2019-10-28 16:30 UTC (permalink / raw)
  To: Jae Hyun Yoo
  Cc: linux-aspeed, Andrew Jeffery, Kangjie Lu, openbmc, Eddie James,
	LKML, Navid Emamdoost, Stephen McCamant, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-media

On Mon, Oct 28, 2019 at 11:27 AM Jae Hyun Yoo
<jae.hyun.yoo@linux.intel.com> wrote:
>
> Hi Navid,
>
> On 10/25/2019 9:25 PM, Navid Emamdoost wrote:
> > In the implementation of aspeed_video_probe() the allocated memory for
> > video should be released in case of failure. Release video if either
> > devm_ioremap_resource() or aspeed_video_init() or
> > aspeed_video_setup_video() fails.
> >
> > Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> >   drivers/media/platform/aspeed-video.c | 14 ++++++++++----
> >   1 file changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> > index eb12f3793062..8c473356132d 100644
> > --- a/drivers/media/platform/aspeed-video.c
> > +++ b/drivers/media/platform/aspeed-video.c
> > @@ -1663,18 +1663,24 @@ static int aspeed_video_probe(struct platform_device *pdev)
> >
> >       video->base = devm_ioremap_resource(video->dev, res);
> >
> > -     if (IS_ERR(video->base))
> > -             return PTR_ERR(video->base);
> > +     if (IS_ERR(video->base)) {
> > +             rc = PTR_ERR(video->base);
> > +             goto free_video;
> > +     }
> >
> >       rc = aspeed_video_init(video);
> >       if (rc)
> > -             return rc;
> > +             goto free_video;
> >
> >       rc = aspeed_video_setup_video(video);
> >       if (rc)
> > -             return rc;
> > +             goto free_video;
> >
> >       return 0;
> > +
> > +free_video:
> > +     kfree(video);
> > +     return rc;
> >   }
> >
> >   static int aspeed_video_remove(struct platform_device *pdev)
> >
>
> Can we simply change kzalloc in aspeed_video_probe with devm_kzalloc
> so that we don't need to take care of freeing of video? I think it would
> be more simpler.

Sounds a neat plan, will send v2.

>
> Cheers,
>
> Jae



-- 
Navid.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 16:27 ` Jae Hyun Yoo
  2019-10-28 16:30   ` Navid Emamdoost
@ 2019-10-28 16:58   ` Navid Emamdoost
  2019-10-28 17:01     ` Jae Hyun Yoo
  1 sibling, 1 reply; 11+ messages in thread
From: Navid Emamdoost @ 2019-10-28 16:58 UTC (permalink / raw)
  To: jae.hyun.yoo
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-media, linux-kernel, emamd001, Joel Stanley, smccaman,
	Mauro Carvalho Chehab, linux-arm-kernel, Navid Emamdoost

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 <navid.emamdoost@gmail.com>
---
Changes in v2:
	-- replace kzalloc with devm_kzalloc based on Jae Hyun Yoo
suggestion

 drivers/media/platform/aspeed-video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index eb12f3793062..2aa8ea2f9824 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -1646,7 +1646,7 @@ 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(sizeof(*video), GFP_KERNEL);
 
 	if (!video)
 		return -ENOMEM;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 16:58   ` [PATCH v2] " Navid Emamdoost
@ 2019-10-28 17:01     ` Jae Hyun Yoo
  2019-10-28 17:06       ` Navid Emamdoost
  0 siblings, 1 reply; 11+ messages in thread
From: Jae Hyun Yoo @ 2019-10-28 17:01 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-kernel, emamd001, Joel Stanley, smccaman,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-media

On 10/28/2019 9:58 AM, Navid Emamdoost wrote:
> 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 <navid.emamdoost@gmail.com>
> ---
> Changes in v2:
> 	-- replace kzalloc with devm_kzalloc based on Jae Hyun Yoo
> suggestion
> 
>   drivers/media/platform/aspeed-video.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..2aa8ea2f9824 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1646,7 +1646,7 @@ 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(sizeof(*video), GFP_KERNEL);

It can't be compiled. devm_kzalloc should have 3 parameters.

Cheers,

Jae

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 17:01     ` Jae Hyun Yoo
@ 2019-10-28 17:06       ` Navid Emamdoost
  2019-10-28 17:08         ` Jae Hyun Yoo
  0 siblings, 1 reply; 11+ messages in thread
From: Navid Emamdoost @ 2019-10-28 17:06 UTC (permalink / raw)
  To: Jae Hyun Yoo
  Cc: linux-aspeed, Andrew Jeffery, Kangjie Lu, openbmc, Eddie James,
	LKML, Navid Emamdoost, Joel Stanley, Stephen McCamant,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-media

On Mon, Oct 28, 2019 at 12:01 PM Jae Hyun Yoo
<jae.hyun.yoo@linux.intel.com> wrote:
>
> On 10/28/2019 9:58 AM, Navid Emamdoost wrote:
> > 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 <navid.emamdoost@gmail.com>
> > ---
> > Changes in v2:
> >       -- replace kzalloc with devm_kzalloc based on Jae Hyun Yoo
> > suggestion
> >
> >   drivers/media/platform/aspeed-video.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> > index eb12f3793062..2aa8ea2f9824 100644
> > --- a/drivers/media/platform/aspeed-video.c
> > +++ b/drivers/media/platform/aspeed-video.c
> > @@ -1646,7 +1646,7 @@ 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(sizeof(*video), GFP_KERNEL);
>
> It can't be compiled. devm_kzalloc should have 3 parameters.
>

Oops! my bad. Do you think such a list of parameters is fine:
    devm_kzalloc(&pdev->dev, sizeof(*video), GFP_KERNEL);

> Cheers,
>
> Jae



-- 
Navid.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 17:06       ` Navid Emamdoost
@ 2019-10-28 17:08         ` Jae Hyun Yoo
  2019-10-28 17:18           ` [PATCH v3] " Navid Emamdoost
  0 siblings, 1 reply; 11+ messages in thread
From: Jae Hyun Yoo @ 2019-10-28 17:08 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: linux-aspeed, Andrew Jeffery, Kangjie Lu, openbmc, Eddie James,
	LKML, Navid Emamdoost, Joel Stanley, Stephen McCamant,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-media

On 10/28/2019 10:06 AM, Navid Emamdoost wrote:
> On Mon, Oct 28, 2019 at 12:01 PM Jae Hyun Yoo
> <jae.hyun.yoo@linux.intel.com> wrote:
>>
>> On 10/28/2019 9:58 AM, Navid Emamdoost wrote:
>>> 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 <navid.emamdoost@gmail.com>
>>> ---
>>> Changes in v2:
>>>        -- replace kzalloc with devm_kzalloc based on Jae Hyun Yoo
>>> suggestion
>>>
>>>    drivers/media/platform/aspeed-video.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
>>> index eb12f3793062..2aa8ea2f9824 100644
>>> --- a/drivers/media/platform/aspeed-video.c
>>> +++ b/drivers/media/platform/aspeed-video.c
>>> @@ -1646,7 +1646,7 @@ 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(sizeof(*video), GFP_KERNEL);
>>
>> It can't be compiled. devm_kzalloc should have 3 parameters.
>>
> 
> Oops! my bad. Do you think such a list of parameters is fine:
>      devm_kzalloc(&pdev->dev, sizeof(*video), GFP_KERNEL);

Yes, it's fine.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 17:08         ` Jae Hyun Yoo
@ 2019-10-28 17:18           ` Navid Emamdoost
  2019-10-28 17:55             ` Jae Hyun Yoo
  2019-11-08 20:37             ` Eddie James
  0 siblings, 2 replies; 11+ messages in thread
From: Navid Emamdoost @ 2019-10-28 17:18 UTC (permalink / raw)
  To: jae.hyun.yoo
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-media, linux-kernel, emamd001, Joel Stanley, smccaman,
	Mauro Carvalho Chehab, linux-arm-kernel, Navid Emamdoost

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 <navid.emamdoost@gmail.com>
---
Changes in v3:
	-- fix call to devm_kzalloc()
---
 drivers/media/platform/aspeed-video.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
index eb12f3793062..70797b41447c 100644
--- a/drivers/media/platform/aspeed-video.c
+++ b/drivers/media/platform/aspeed-video.c
@@ -1646,7 +1646,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;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 17:18           ` [PATCH v3] " Navid Emamdoost
@ 2019-10-28 17:55             ` Jae Hyun Yoo
  2019-11-08 20:37             ` Eddie James
  1 sibling, 0 replies; 11+ messages in thread
From: Jae Hyun Yoo @ 2019-10-28 17:55 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-kernel, emamd001, smccaman, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-media

On 10/28/2019 10:18 AM, Navid Emamdoost wrote:
> 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 <navid.emamdoost@gmail.com>
> ---
> Changes in v3:
> 	-- fix call to devm_kzalloc()

Better keep all change history at here.

> ---
>   drivers/media/platform/aspeed-video.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..70797b41447c 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1646,7 +1646,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);

For a case of assignment in definition section, let it go over the 80
chars.

With this fixed:

Reviewed-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>

>   	if (!video)
>   		return -ENOMEM;
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] media: aspeed-video: Fix memory leaks in aspeed_video_probe
  2019-10-28 17:18           ` [PATCH v3] " Navid Emamdoost
  2019-10-28 17:55             ` Jae Hyun Yoo
@ 2019-11-08 20:37             ` Eddie James
  1 sibling, 0 replies; 11+ messages in thread
From: Eddie James @ 2019-11-08 20:37 UTC (permalink / raw)
  To: Navid Emamdoost, jae.hyun.yoo
  Cc: linux-aspeed, Andrew Jeffery, kjlu, openbmc, Eddie James,
	linux-kernel, emamd001, smccaman, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-media


On 10/28/19 12:18 PM, Navid Emamdoost wrote:
> 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.


Thanks,

Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
> Fixes: d2b4387f3bdf ("media: platform: Add Aspeed Video Engine driver")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> Changes in v3:
> 	-- fix call to devm_kzalloc()
> ---
>   drivers/media/platform/aspeed-video.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c
> index eb12f3793062..70797b41447c 100644
> --- a/drivers/media/platform/aspeed-video.c
> +++ b/drivers/media/platform/aspeed-video.c
> @@ -1646,7 +1646,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;

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-11-08 20:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-26  4:25 [PATCH] media: aspeed-video: Fix memory leaks in aspeed_video_probe Navid Emamdoost
2019-10-27  6:55 ` Markus Elfring
2019-10-28 16:27 ` Jae Hyun Yoo
2019-10-28 16:30   ` Navid Emamdoost
2019-10-28 16:58   ` [PATCH v2] " Navid Emamdoost
2019-10-28 17:01     ` Jae Hyun Yoo
2019-10-28 17:06       ` Navid Emamdoost
2019-10-28 17:08         ` Jae Hyun Yoo
2019-10-28 17:18           ` [PATCH v3] " Navid Emamdoost
2019-10-28 17:55             ` Jae Hyun Yoo
2019-11-08 20:37             ` Eddie James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).