* [PATCH] drm: sgdma: free allocated memory if TT init fails
@ 2014-12-10 18:37 Alexandre Courbot
[not found] ` <1418236637-15053-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Courbot @ 2014-12-10 18:37 UTC (permalink / raw)
To: Ben Skeggs; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
When ttm_dma_tt_init() fails in nouveau_sgdma_create_ttm(), we should
free the previously allocated memory before returning NULL.
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
drm/nouveau_sgdma.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drm/nouveau_sgdma.c b/drm/nouveau_sgdma.c
index 01707e7deaf5..e4fc494d688d 100644
--- a/drm/nouveau_sgdma.c
+++ b/drm/nouveau_sgdma.c
@@ -107,7 +107,10 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
else
nvbe->ttm.ttm.func = &nv50_sgdma_backend;
- if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
+ if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) {
+ kfree(nvbe);
return NULL;
+ }
+
return &nvbe->ttm.ttm;
}
--
2.1.3
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sgdma: free allocated memory if TT init fails
[not found] ` <1418236637-15053-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2014-12-10 18:47 ` Ilia Mirkin
[not found] ` <CAKb7UvgOwK469E6z_nEC+UHXVgs5d-6rNFiwiqApO63tbs2P6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Ilia Mirkin @ 2014-12-10 18:47 UTC (permalink / raw)
To: Alexandre Courbot
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
We get this patch every few months... How about one that instead adds
a comment which explains why this kfree isn't needed :) [I'm leaving
the reason to the reader, which will force you to glance at the ttm
code.]
On Wed, Dec 10, 2014 at 1:37 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> When ttm_dma_tt_init() fails in nouveau_sgdma_create_ttm(), we should
> free the previously allocated memory before returning NULL.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> drm/nouveau_sgdma.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drm/nouveau_sgdma.c b/drm/nouveau_sgdma.c
> index 01707e7deaf5..e4fc494d688d 100644
> --- a/drm/nouveau_sgdma.c
> +++ b/drm/nouveau_sgdma.c
> @@ -107,7 +107,10 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev,
> else
> nvbe->ttm.ttm.func = &nv50_sgdma_backend;
>
> - if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page))
> + if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) {
> + kfree(nvbe);
> return NULL;
> + }
> +
> return &nvbe->ttm.ttm;
> }
> --
> 2.1.3
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sgdma: free allocated memory if TT init fails
[not found] ` <CAKb7UvgOwK469E6z_nEC+UHXVgs5d-6rNFiwiqApO63tbs2P6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2014-12-10 18:58 ` Alexandre Courbot
[not found] ` <548897C2.8020401-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Courbot @ 2014-12-10 18:58 UTC (permalink / raw)
To: Ilia Mirkin
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
On 12/11/2014 03:47 AM, Ilia Mirkin wrote:
> We get this patch every few months... How about one that instead adds
> a comment which explains why this kfree isn't needed :) [I'm leaving
> the reason to the reader, which will force you to glance at the ttm
> code.]
ttm_dma_tt_init -> ttm_tt_destroy -> nouveau_sgdma_destroy -> kfree
Urrk.
I'm definitely not a fan of things happening this way, but let it be.
Indeed a comment would be nice to have here, let me prep a patch for
this instead...
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm: sgdma: free allocated memory if TT init fails
[not found] ` <548897C2.8020401-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2014-12-10 22:07 ` Ben Skeggs
0 siblings, 0 replies; 4+ messages in thread
From: Ben Skeggs @ 2014-12-10 22:07 UTC (permalink / raw)
To: Alexandre Courbot
Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Ben Skeggs
On Thu, Dec 11, 2014 at 4:58 AM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> On 12/11/2014 03:47 AM, Ilia Mirkin wrote:
>>
>> We get this patch every few months... How about one that instead adds
>> a comment which explains why this kfree isn't needed :) [I'm leaving
>> the reason to the reader, which will force you to glance at the ttm
>> code.]
I'd quite like it if people looked at a bit more context for sending
such patches......
>
>
> ttm_dma_tt_init -> ttm_tt_destroy -> nouveau_sgdma_destroy -> kfree
>
> Urrk.
..... That said.. I made the same mistake myself a few years back ;)
>
> I'm definitely not a fan of things happening this way, but let it be.
>
> Indeed a comment would be nice to have here, let me prep a patch for this
> instead...
I've picked up all three patches.
Thanks,
Ben.
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-10 22:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-10 18:37 [PATCH] drm: sgdma: free allocated memory if TT init fails Alexandre Courbot
[not found] ` <1418236637-15053-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-12-10 18:47 ` Ilia Mirkin
[not found] ` <CAKb7UvgOwK469E6z_nEC+UHXVgs5d-6rNFiwiqApO63tbs2P6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-10 18:58 ` Alexandre Courbot
[not found] ` <548897C2.8020401-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2014-12-10 22:07 ` Ben Skeggs
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.