Mikko Perttunen
2021-Jun-11 14:18 UTC
[Nouveau] [PATCH] drm/nouveau/gk20a: fix NULL dereference on allocation failure
If memory allocation fails, `node->base.imem` does not get populated, causing a NULL pointer dereference on instobj destruction. Fix this by dereferencing it only if the allocation was successful. Signed-off-by: Mikko Perttunen <mperttunen at nvidia.com> --- drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c index 648ecf5a8fbc..66d60d8bec60 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -296,12 +296,12 @@ gk20a_instobj_dtor_dma(struct nvkm_memory *memory) { struct gk20a_instobj_dma *node = gk20a_instobj_dma(memory); struct gk20a_instmem *imem = node->base.imem; - struct device *dev = imem->base.subdev.device->dev; if (unlikely(!node->base.vaddr)) goto out; - dma_free_attrs(dev, (u64)node->base.mn->length << PAGE_SHIFT, + dma_free_attrs(imem->base.subdev.device->dev, + (u64)node->base.mn->length << PAGE_SHIFT, node->base.vaddr, node->handle, imem->attrs); out: -- 2.30.1