Skip to contentSkip to conversation

drm/amd/amdgpu/amdgpu_ttm: Handle return NULL error from ioremap_nocache

PATCH In review Arvind Yadav 3 participants 3 messages Jan 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu/amdgpu_ttm: Handle return NULL error from ioremap_nocache

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -0
index 8e35c1f..610c88f 100644
@@ -552,6 +552,8 @@ static int amdgpu_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
Signature · 1 line
1.9.1
#1 lore raw

Am 24.01.2017 um 10:25 schrieb Arvind Yadav:

Quoted 5 lines

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.

I'm not 100% sure if ioremap_nocache() can actually return NULL on platforms where this matters, but if that's the case the patch looks reasonable on first glance.

So it is Reviewed-by: Christian König <[email protected]>.

Regards,
Christian.

Quoted 9 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 8e35c1f..610c88f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_ · line 559

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -0
@@ -552,6 +552,8 @@ static int amdgpu_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

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 6 lines · Christian König

Am 24.01.2017 um 10:25 schrieb Arvind Yadav:

Quoted 5 lines

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.

Quoted 9 lines
Quoted 1 line

I'm not 100% sure if ioremap_nocache() can actually return NULL on platforms where this matters, but if that's the case the patch looks reasonable on first glance.

So it is Reviewed-by: Christian König <[email protected]>.

Applied this and the radeon patch.

Alex

Quoted 21 lines

Regards,
Christian.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 8e35c1f..610c88f 100644
@@ -552,6 +552,8 @@ static int amdgpu_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);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -0
+               if (!mem->bus.addr)
+                       return -ENOMEM;
                /*
Quoted 8 lines
Quoted 1 line

* Alpha: Use just the bus offset plus

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel