video: tegra: host: Fix error case memory leaks
Terje Bergstrom [Tue, 29 May 2012 15:30:16 +0000 (18:30 +0300)]
When a submit fails, the related nvhost_job is not freed. Add an
explicit free. Also, 3D is mapping the save buffer, but it is not
unmapped.

Bug 991972

Change-Id: Ie335adb5e64f54557e76d12dfb6a9a1557781e8d
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: http://git-master/r/105152
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mayuresh Kulkarni <mkulkarni@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/gr3d/gr3d_t30.c

index 87aa9c6..12e0a04 100644 (file)
@@ -182,6 +182,11 @@ static void reset_submit(struct nvhost_channel_userctx *ctx)
        ctx->hdr.num_relocs = 0;
        ctx->num_relocshifts = 0;
        ctx->hdr.num_waitchks = 0;
+
+       if (ctx->job) {
+               nvhost_job_put(ctx->job);
+               ctx->job = NULL;
+       }
 }
 
 static ssize_t nvhost_channelwrite(struct file *filp, const char __user *buf,
index 57f4c77..4bc7c9f 100644 (file)
@@ -427,6 +427,8 @@ struct nvhost_hwctx_handler *nvhost_gr3d_t30_ctxhandler_init(
 
        setup_save(p, save_ptr);
 
+       nvmap_munmap(p->save_buf, save_ptr);
+
        p->h.alloc = ctx3d_alloc_v1;
        p->h.save_push = save_push_v1;
        p->h.save_service = NULL;