* [PATCH] drm/omap: fix memory leak when FB init fails
@ 2017-08-04 9:24 Tomi Valkeinen
2017-08-07 11:29 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Tomi Valkeinen @ 2017-08-04 9:24 UTC (permalink / raw)
To: Laurent Pinchart, dri-devel, Jyri Sarha; +Cc: Tomi Valkeinen
omap_framebuffer_create() fails to unref all the gem objects if creating
the FB fails, leading to a memory leak.
Fix the loop so that it goes through all the reffed gem objects.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---
drivers/gpu/drm/omapdrm/omap_fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index ddf7a457951b..b1a762b70cbf 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -379,7 +379,7 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
return fb;
error:
- while (--i > 0)
+ while (--i >= 0)
drm_gem_object_unreference_unlocked(bos[i]);
return fb;
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/omap: fix memory leak when FB init fails
2017-08-04 9:24 [PATCH] drm/omap: fix memory leak when FB init fails Tomi Valkeinen
@ 2017-08-07 11:29 ` Laurent Pinchart
2017-08-07 11:50 ` Tomi Valkeinen
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2017-08-07 11:29 UTC (permalink / raw)
To: Tomi Valkeinen; +Cc: Jyri Sarha, dri-devel
Hi Tomi,
Thank you for the patch.
On Friday 04 Aug 2017 12:24:10 Tomi Valkeinen wrote:
> omap_framebuffer_create() fails to unref all the gem objects if creating
> the FB fails, leading to a memory leak.
>
> Fix the loop so that it goes through all the reffed gem objects.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> ---
> drivers/gpu/drm/omapdrm/omap_fb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c
> b/drivers/gpu/drm/omapdrm/omap_fb.c index ddf7a457951b..b1a762b70cbf 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
> @@ -379,7 +379,7 @@ struct drm_framebuffer *omap_framebuffer_create(struct
> drm_device *dev, return fb;
>
> error:
> - while (--i > 0)
> + while (--i >= 0)
How about i-- > 0 ? That way we could make i an unsigned int as it should be,
given that a negative array index doesn't make sense here.
> drm_gem_object_unreference_unlocked(bos[i]);
>
> return fb;
--
Regards,
Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/omap: fix memory leak when FB init fails
2017-08-07 11:29 ` Laurent Pinchart
@ 2017-08-07 11:50 ` Tomi Valkeinen
0 siblings, 0 replies; 3+ messages in thread
From: Tomi Valkeinen @ 2017-08-07 11:50 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: Jyri Sarha, dri-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 1313 bytes --]
On 07/08/17 14:29, Laurent Pinchart wrote:
> Hi Tomi,
>
> Thank you for the patch.
>
> On Friday 04 Aug 2017 12:24:10 Tomi Valkeinen wrote:
>> omap_framebuffer_create() fails to unref all the gem objects if creating
>> the FB fails, leading to a memory leak.
>>
>> Fix the loop so that it goes through all the reffed gem objects.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> ---
>> drivers/gpu/drm/omapdrm/omap_fb.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c
>> b/drivers/gpu/drm/omapdrm/omap_fb.c index ddf7a457951b..b1a762b70cbf 100644
>> --- a/drivers/gpu/drm/omapdrm/omap_fb.c
>> +++ b/drivers/gpu/drm/omapdrm/omap_fb.c
>> @@ -379,7 +379,7 @@ struct drm_framebuffer *omap_framebuffer_create(struct
>> drm_device *dev, return fb;
>>
>> error:
>> - while (--i > 0)
>> + while (--i >= 0)
>
> How about i-- > 0 ? That way we could make i an unsigned int as it should be,
> given that a negative array index doesn't make sense here.
I tried that too, but I think it's a bit confusing. It's nice to see the
limit of the iteration directly from the comparison, and with i--, we
decrease i after the comparison. So "> 0" actually means ">= 0 inside
the body of the while loop"...
Tomi
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-07 11:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-04 9:24 [PATCH] drm/omap: fix memory leak when FB init fails Tomi Valkeinen
2017-08-07 11:29 ` Laurent Pinchart
2017-08-07 11:50 ` Tomi Valkeinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.