drm/rockchip: fix dma_alloc_attrs() error check
authorDaniel Kurtz <djkurtz@chromium.org>
Wed, 7 Jan 2015 09:27:06 +0000 (17:27 +0800)
committerMark Yao <mark.yao@rock-chips.com>
Fri, 9 Jan 2015 03:29:06 +0000 (11:29 +0800)
dma_alloc_attrs() returns NULL if it cannot allocate a dma buffer (or
mapping), not a negative error code.

Rerported-by: Pawel Osciak <posciak@chromium.org>
Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Mark Yao <mark.yao@rock-chips.com>
drivers/gpu/drm/rockchip/rockchip_drm_gem.c

index bc98a227dc767085f04774be57dea25a793f5376..7ca8799ef78498ca84cc3a48f1265d2f1ce2f6c9 100644 (file)
@@ -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;