Skip to content

Commit 29cd13c

Browse files
Navidemdanvet
authored andcommitted
drm/v3d: Fix memory leak in v3d_submit_cl_ioctl
In the impelementation of v3d_submit_cl_ioctl() there are two memory leaks. One is when allocation for bin fails, and the other is when bin initialization fails. If kcalloc fails to allocate memory for bin then render->base should be put. Also, if v3d_job_init() fails to initialize bin->base then allocated memory for bin should be released. Fixes: a783a09 ("drm/v3d: Refactor job management.") Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20191021185250.26130-1-navid.emamdoost@gmail.com
1 parent 4cad2a5 commit 29cd13c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: drivers/gpu/drm/v3d/v3d_gem.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,16 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
557557

558558
if (args->bcl_start != args->bcl_end) {
559559
bin = kcalloc(1, sizeof(*bin), GFP_KERNEL);
560-
if (!bin)
560+
if (!bin) {
561+
v3d_job_put(&render->base);
561562
return -ENOMEM;
563+
}
562564

563565
ret = v3d_job_init(v3d, file_priv, &bin->base,
564566
v3d_job_free, args->in_sync_bcl);
565567
if (ret) {
566568
v3d_job_put(&render->base);
569+
kfree(bin);
567570
return ret;
568571
}
569572

0 commit comments

Comments
 (0)