Alexandre Courbot
2014-Dec-10 19:07 UTC
[Nouveau] [PATCH] drm: sgdma: add comment around suspiscious error handler
Common programming sense dictates that resources allocated by a function are freed by this function should it fails, but this is not the case for the allocated structure of nouveau_sgdma_create_ttm(). It seems that n00b contributors attempt to fix this one like bugs flying towards a bug zapper, so add a comment to hopefully prevent this from happening anymore. Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> --- drm/nouveau_sgdma.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drm/nouveau_sgdma.c b/drm/nouveau_sgdma.c index ec76c0b4e452..23c377a6c761 100644 --- a/drm/nouveau_sgdma.c +++ b/drm/nouveau_sgdma.c @@ -106,6 +106,11 @@ nouveau_sgdma_create_ttm(struct ttm_bo_device *bdev, nvbe->ttm.ttm.func = &nv50_sgdma_backend; if (ttm_dma_tt_init(&nvbe->ttm, bdev, size, page_flags, dummy_read_page)) + /* + * A failing ttm_dma_tt_init() will call ttm_tt_destroy() + * and thus our nouveau_sgdma_destroy() hook, so we don't need + * to free nvbe here. + */ return NULL; return &nvbe->ttm.ttm; } -- 2.1.3
Apparently Analagous Threads
- [PATCH] drm: sgdma: free allocated memory if TT init fails
- [PATCH] drm: sgdma: free allocated memory if TT init fails
- [PATCH] drm: sgdma: remove unused nouveau_sgdma_be::dev
- [PATCH] ttm/drm: constify ttm_backend_func structures
- [PATCH] ttm/drm: constify ttm_backend_func structures