Skip to contentSkip to conversation

instmem/gk20a: fix crash during error path

PATCH In review Alexandre Courbot 2 participants 2 messages Mar 10, 2015 – Mar 11, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 instmem/gk20a: fix crash during error path

If a memory allocation fails when using the DMA allocator, gk20a_instobj_dtor_dma() will be called on the failed instmem object. At this time, node->handle might not be NULL despite the call to dma_alloc_attrs() having failed. node->cpuaddr is the right member to check for such a failure, so use it instead.

---
 drm/nouveau/nvkm/subdev/instmem/gk20a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drm/nouveau/nvkm/subdev/instmem/gk20a.c +1 -1
index fcba72eb74a3..dd0994d9ebfc 100644
@@ -148,7 +148,7 @@ gk20a_instobj_dtor_dma(struct gk20a_instobj_priv *_node)
 	struct gk20a_instmem_priv *priv = (void *)nvkm_instmem(node);
 	struct device *dev = nv_device_base(nv_device(priv));
 
-	if (unlikely(!node->handle))
+	if (unlikely(!node->cpuaddr))
 		return;
 
 	dma_free_attrs(dev, _node->mem->size << PAGE_SHIFT, node->cpuaddr,
Signature · 1 line
2.3.2

A message that is not in the archive (sent off-list or not yet received): 1425969968-25691-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 5 lines · Alexandre Courbot

If a memory allocation fails when using the DMA allocator, gk20a_instobj_dtor_dma() will be called on the failed instmem object. At this time, node->handle might not be NULL despite the call to dma_alloc_attrs() having failed. node->cpuaddr is the right member to check for such a failure, so use it instead.

Indeed. The DMA address handle is in fact the very opposite of 0 in the failure case (DMA_ERROR_CODE).

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau