media: vsp1: fix memory leak of dl on error return path
authorColin Ian King <colin.king@canonical.com>
Sun, 28 Jul 2019 17:11:24 +0000 (14:11 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Wed, 14 Aug 2019 19:00:59 +0000 (16:00 -0300)
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>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/vsp1/vsp1_dl.c

index 104b6f5145364eeb63a03b0739611c13e4aff398..d7b43037e500a83baed4f6f8f261390b3f3d71d3 100644 (file)
@@ -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);