Skip to content

Commit 2be6564

Browse files
ccrtnspdanvet
authored andcommitted
drm/nouveau: fix relocations applying logic and a double-free
Commit 03e0d26 ("drm/nouveau: slowpath for pushbuf ioctl") included a logic-bug which results in the relocations not actually getting applied at all as the call to nouveau_gem_pushbuf_reloc_apply() is never reached. This causes a regression with graphical corruption, triggered when relocations need to be done (for example after a suspend/resume cycle.) Fix by setting *apply_relocs value only if there were more than 0 relocations. Additionally, the never reached code had a leftover u_free() call, which, after fixing the logic, now got called and resulted in a double-free. Fix by removing one u_free(), moving the other and adding check for errors. Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: nouveau@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Signed-off-by: Matti Hamalainen <ccr@tnsp.org> Fixes: 03e0d26 ("drm/nouveau: slowpath for pushbuf ioctl") References: https://gitlab.freedesktop.org/drm/nouveau/-/issues/11 Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: https://patchwork.freedesktop.org/patch/msgid/20201120152338.1203257-1-ccr@tnsp.org
1 parent 10e26e7 commit 2be6564

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,10 @@ nouveau_gem_pushbuf_validate(struct nouveau_channel *chan,
558558
NV_PRINTK(err, cli, "validating bo list\n");
559559
validate_fini(op, chan, NULL, NULL);
560560
return ret;
561+
} else if (ret > 0) {
562+
*apply_relocs = true;
561563
}
562-
*apply_relocs = ret;
564+
563565
return 0;
564566
}
565567

@@ -662,7 +664,6 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_cli *cli,
662664
nouveau_bo_wr32(nvbo, r->reloc_bo_offset >> 2, data);
663665
}
664666

665-
u_free(reloc);
666667
return ret;
667668
}
668669

@@ -872,9 +873,10 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
872873
break;
873874
}
874875
}
875-
u_free(reloc);
876876
}
877877
out_prevalid:
878+
if (!IS_ERR(reloc))
879+
u_free(reloc);
878880
u_free(bo);
879881
u_free(push);
880882

0 commit comments

Comments
 (0)