* [PATCH] media: vsp1: fix memory leak of dl on error return path
@ 2019-07-28 17:11 Colin King
2019-07-29 12:11 ` Kieran Bingham
0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2019-07-28 17:11 UTC (permalink / raw)
To: Laurent Pinchart, Kieran Bingham, Mauro Carvalho Chehab,
linux-media, linux-renesas-soc
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently when the call vsp1_dl_body_get fails and returns null the
error return path leaks the allocation of dl. Fix this by kfree'ing
dl before returning.
Addresses-Coverity: ("Resource leak")
Fixes: 5d7936b8e27d ("media: vsp1: Convert display lists to use new body pool")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/media/platform/vsp1/vsp1_dl.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
index 104b6f514536..d7b43037e500 100644
--- a/drivers/media/platform/vsp1/vsp1_dl.c
+++ b/drivers/media/platform/vsp1/vsp1_dl.c
@@ -557,8 +557,10 @@ static struct vsp1_dl_list *vsp1_dl_list_alloc(struct vsp1_dl_manager *dlm)
/* Get a default body for our list. */
dl->body0 = vsp1_dl_body_get(dlm->pool);
- if (!dl->body0)
+ if (!dl->body0) {
+ kfree(dl);
return NULL;
+ }
header_offset = dl->body0->max_entries * sizeof(*dl->body0->entries);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: vsp1: fix memory leak of dl on error return path
2019-07-28 17:11 [PATCH] media: vsp1: fix memory leak of dl on error return path Colin King
@ 2019-07-29 12:11 ` Kieran Bingham
2019-07-29 12:12 ` Colin Ian King
0 siblings, 1 reply; 4+ messages in thread
From: Kieran Bingham @ 2019-07-29 12:11 UTC (permalink / raw)
To: Colin King, Laurent Pinchart, Mauro Carvalho Chehab, linux-media,
linux-renesas-soc
Cc: kernel-janitors, linux-kernel
Hi Colin,
On 28/07/2019 18:11, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently when the call vsp1_dl_body_get fails and returns null the
> error return path leaks the allocation of dl. Fix this by kfree'ing
> dl before returning.
Eeep. This does indeed look to be the case.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: 5d7936b8e27d ("media: vsp1: Convert display lists to use new body pool")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Thank you!
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> ---
> drivers/media/platform/vsp1/vsp1_dl.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
> index 104b6f514536..d7b43037e500 100644
> --- a/drivers/media/platform/vsp1/vsp1_dl.c
> +++ b/drivers/media/platform/vsp1/vsp1_dl.c
> @@ -557,8 +557,10 @@ static struct vsp1_dl_list *vsp1_dl_list_alloc(struct vsp1_dl_manager *dlm)
>
> /* Get a default body for our list. */
> dl->body0 = vsp1_dl_body_get(dlm->pool);
> - if (!dl->body0)
> + if (!dl->body0) {
> + kfree(dl);
> return NULL;
> + }
>
> header_offset = dl->body0->max_entries * sizeof(*dl->body0->entries);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: vsp1: fix memory leak of dl on error return path
2019-07-29 12:11 ` Kieran Bingham
@ 2019-07-29 12:12 ` Colin Ian King
2019-07-29 12:14 ` Kieran Bingham
0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2019-07-29 12:12 UTC (permalink / raw)
To: kieran.bingham+renesas, Laurent Pinchart, Mauro Carvalho Chehab,
linux-media, linux-renesas-soc
Cc: kernel-janitors, linux-kernel
On 29/07/2019 13:11, Kieran Bingham wrote:
> Hi Colin,
>
> On 28/07/2019 18:11, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently when the call vsp1_dl_body_get fails and returns null the
>> error return path leaks the allocation of dl. Fix this by kfree'ing
>> dl before returning.
>
> Eeep. This does indeed look to be the case.
>
>>
>> Addresses-Coverity: ("Resource leak")
>> Fixes: 5d7936b8e27d ("media: vsp1: Convert display lists to use new body pool")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>
> Thank you!
Thank static analysis :-)
>
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>
>
>> ---
>> drivers/media/platform/vsp1/vsp1_dl.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
>> index 104b6f514536..d7b43037e500 100644
>> --- a/drivers/media/platform/vsp1/vsp1_dl.c
>> +++ b/drivers/media/platform/vsp1/vsp1_dl.c
>> @@ -557,8 +557,10 @@ static struct vsp1_dl_list *vsp1_dl_list_alloc(struct vsp1_dl_manager *dlm)
>>
>> /* Get a default body for our list. */
>> dl->body0 = vsp1_dl_body_get(dlm->pool);
>> - if (!dl->body0)
>> + if (!dl->body0) {
>> + kfree(dl);
>> return NULL;
>> + }
>>
>> header_offset = dl->body0->max_entries * sizeof(*dl->body0->entries);
>>
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: vsp1: fix memory leak of dl on error return path
2019-07-29 12:12 ` Colin Ian King
@ 2019-07-29 12:14 ` Kieran Bingham
0 siblings, 0 replies; 4+ messages in thread
From: Kieran Bingham @ 2019-07-29 12:14 UTC (permalink / raw)
To: Colin Ian King, Laurent Pinchart, Mauro Carvalho Chehab,
linux-media, linux-renesas-soc
Cc: kernel-janitors, linux-kernel
On 29/07/2019 13:12, Colin Ian King wrote:
> On 29/07/2019 13:11, Kieran Bingham wrote:
>> Hi Colin,
>>
>> On 28/07/2019 18:11, Colin King wrote:
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Currently when the call vsp1_dl_body_get fails and returns null the
>>> error return path leaks the allocation of dl. Fix this by kfree'ing
>>> dl before returning.
>>
>> Eeep. This does indeed look to be the case.
>>
>>>
>>> Addresses-Coverity: ("Resource leak")
>>> Fixes: 5d7936b8e27d ("media: vsp1: Convert display lists to use new body pool")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>
>> Thank you!
>
> Thank static analysis :-)
Bah, that's just the hammer - you're the one finding the nails :-D
--
Kieran
>
>>
>> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>>
>>
>>> ---
>>> drivers/media/platform/vsp1/vsp1_dl.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
>>> index 104b6f514536..d7b43037e500 100644
>>> --- a/drivers/media/platform/vsp1/vsp1_dl.c
>>> +++ b/drivers/media/platform/vsp1/vsp1_dl.c
>>> @@ -557,8 +557,10 @@ static struct vsp1_dl_list *vsp1_dl_list_alloc(struct vsp1_dl_manager *dlm)
>>>
>>> /* Get a default body for our list. */
>>> dl->body0 = vsp1_dl_body_get(dlm->pool);
>>> - if (!dl->body0)
>>> + if (!dl->body0) {
>>> + kfree(dl);
>>> return NULL;
>>> + }
>>>
>>> header_offset = dl->body0->max_entries * sizeof(*dl->body0->entries);
>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-07-29 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-28 17:11 [PATCH] media: vsp1: fix memory leak of dl on error return path Colin King
2019-07-29 12:11 ` Kieran Bingham
2019-07-29 12:12 ` Colin Ian King
2019-07-29 12:14 ` Kieran Bingham
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).