Alexandre Courbot
2015-Mar-10 06:46 UTC
[Nouveau] [PATCH] 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. Reported-by: Vince Hsu <vinceh at nvidia.com> Signed-off-by: Alexandre Courbot <acourbot at nvidia.com> --- drm/nouveau/nvkm/subdev/instmem/gk20a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drm/nouveau/nvkm/subdev/instmem/gk20a.c index fcba72eb74a3..dd0994d9ebfc 100644 --- a/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -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, -- 2.3.2
Thierry Reding
2015-Mar-11 09:01 UTC
[Nouveau] [PATCH] instmem/gk20a: fix crash during error path
On Tue, Mar 10, 2015 at 03:46:08PM +0900, Alexandre Courbot wrote:> 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). Reviewed-by: Thierry Reding <treding at nvidia.com> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.freedesktop.org/archives/nouveau/attachments/20150311/988e9d97/attachment.sig>
Possibly Parallel Threads
- [PATCH v2 6/6] instmem/gk20a: add IOMMU support
- [PATCH v2 2/6] instmem/gk20a: move memory allocation to instmem
- [PATCH] instmem/gk20a: use DMA API CPU mapping
- [PATCH 2/6] instmem/gk20a: refer to IOMMU physical translation bit
- [PATCH v3 4/6] instmem/gk20a: use DMA attributes