drm/udl: properly check for error pointers
authorHaixia Shi <hshi@chromium.org>
Tue, 25 Nov 2014 20:04:03 +0000 (12:04 -0800)
committerDave Airlie <airlied@redhat.com>
Wed, 26 Nov 2014 00:03:18 +0000 (10:03 +1000)
The drm_prime_pages_to_sg() function never returns NULL pointers, only
error pointers and valid pointers.

Signed-off-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/udl/udl_dmabuf.c

index 2425b76dc44ce49b5e5d5ea4250fa2427b4c78a0..ac8a66b4dfc2053ec8b8f7314601bb4d30d49e6a 100644 (file)
@@ -99,9 +99,9 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach,
 
        page_count = obj->base.size / PAGE_SIZE;
        obj->sg = drm_prime_pages_to_sg(obj->pages, page_count);
-       if (!obj->sg) {
-               DRM_ERROR("sg is null.\n");
-               return ERR_PTR(-ENOMEM);
+       if (IS_ERR(obj->sg)) {
+               DRM_ERROR("failed to allocate sgt.\n");
+               return ERR_CAST(obj->sg);
        }
 
        sgt = &udl_attach->sgt;