diff mbox

drm/msm: Error pointer dereference in error handling

Message ID 20170811201535.xy4smb52jqo5egtv@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Aug. 11, 2017, 8:15 p.m. UTC
"gpu->aspace" can be either an error pointer or NULL so we need to check
for both.

Fixes: 0dbd7327f4d5 ("drm/msm: Move memptrs to msm_gpu")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Jordan Crouse Aug. 14, 2017, 2:50 p.m. UTC | #1
On Fri, Aug 11, 2017 at 11:15:35PM +0300, Dan Carpenter wrote:
> "gpu->aspace" can be either an error pointer or NULL so we need to check
> for both.
> 
> Fixes: 0dbd7327f4d5 ("drm/msm: Move memptrs to msm_gpu")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> index 66af5ac334ba..156ad7d5c68a 100644
> --- a/drivers/gpu/drm/msm/msm_gpu.c
> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -775,7 +775,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
>  		drm_gem_object_unreference_unlocked(gpu->memptrs_bo);
>  	}
>  
> -	if (gpu->aspace) {
> +	if (!IS_ERR_OR_NULL(gpu->aspace)) {
>  		gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu,
>  			NULL, 0);
>  		msm_gem_address_space_put(gpu->aspace);

Yep, thats clearly a paddlin'.  Thanks.

Acked-by: Jordan Crouse <jcrouse@codeauorora.org>
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index 66af5ac334ba..156ad7d5c68a 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -775,7 +775,7 @@  int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 		drm_gem_object_unreference_unlocked(gpu->memptrs_bo);
 	}
 
-	if (gpu->aspace) {
+	if (!IS_ERR_OR_NULL(gpu->aspace)) {
 		gpu->aspace->mmu->funcs->detach(gpu->aspace->mmu,
 			NULL, 0);
 		msm_gem_address_space_put(gpu->aspace);