drm: radeon: radeon_ttm: Handle return NULL error from ioremap_nocache
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 24 Jan 2017 09:16:16 +0000 (14:46 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 27 Jan 2017 17:20:38 +0000 (12:20 -0500)
Here, If ioremap_nocache will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference.
This error check will avoid NULL pointer dereference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_ttm.c

index 7e3eb8e..7a10b38 100644 (file)
@@ -502,6 +502,8 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_
                        mem->bus.addr =
                                ioremap_nocache(mem->bus.base + mem->bus.offset,
                                                mem->bus.size);
+               if (!mem->bus.addr)
+                       return -ENOMEM;
 
                /*
                 * Alpha: Use just the bus offset plus