From: Daniel Kurtz Date: Wed, 7 Jan 2015 09:27:06 +0000 (+0800) Subject: drm/rockchip: fix dma_alloc_attrs() error check X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4b9a90c0b374f8f7b3ceabe3c202424c98a6c5a4;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drm/rockchip: fix dma_alloc_attrs() error check dma_alloc_attrs() returns NULL if it cannot allocate a dma buffer (or mapping), not a negative error code. Rerported-by: Pawel Osciak Signed-off-by: Daniel Kurtz Signed-off-by: Mark Yao --- diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index bc98a227dc76..7ca8799ef784 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -34,12 +34,9 @@ static int rockchip_gem_alloc_buf(struct rockchip_gem_object *rk_obj) rk_obj->kvaddr = dma_alloc_attrs(drm->dev, obj->size, &rk_obj->dma_addr, GFP_KERNEL, &rk_obj->dma_attrs); - if (IS_ERR(rk_obj->kvaddr)) { - int ret = PTR_ERR(rk_obj->kvaddr); - - DRM_ERROR("failed to allocate %#x byte dma buffer, %d", - obj->size, ret); - return ret; + if (!rk_obj->kvaddr) { + DRM_ERROR("failed to allocate %#x byte dma buffer", obj->size); + return -ENOMEM; } return 0;