All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] drm: fix null pointer dereference on null state pointer
@ 2018-12-22 13:00 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2018-12-22 13:00 UTC (permalink / raw)
  To: Rob Clark, Maarten Lankhorst, Maxime Ripard, Sean Paul,
	David Airlie, Daniel Vetter, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

In the case where state cannot be allocated, the current exit path via
label 'out' will dereference the null state pointer when calling
drm_atomic_state_put. Fix this by adding a new error exit label and
jumping to this to avoid the drm_atomic_state_put.

Detected by CoverityScan, CID#1476034 ("Dereference after null check")

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/drm_damage_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
index d2a1c7372f36..31032407254d 100644
--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -178,7 +178,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 	state = drm_atomic_state_alloc(fb->dev);
 	if (!state) {
 		ret = -ENOMEM;
-		goto out;
+		goto out_drop_locks;
 	}
 	state->acquire_ctx = &ctx;
 
@@ -238,6 +238,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 	kfree(rects);
 	drm_atomic_state_put(state);
 
+out_drop_locks:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH][next] drm: fix null pointer dereference on null state pointer
@ 2018-12-22 13:00 ` Colin King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin King @ 2018-12-22 13:00 UTC (permalink / raw)
  To: Rob Clark, Maarten Lankhorst, Maxime Ripard, Sean Paul,
	David Airlie, Daniel Vetter, dri-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

In the case where state cannot be allocated, the current exit path via
label 'out' will dereference the null state pointer when calling
drm_atomic_state_put. Fix this by adding a new error exit label and
jumping to this to avoid the drm_atomic_state_put.

Detected by CoverityScan, CID#1476034 ("Dereference after null check")

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/drm_damage_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
index d2a1c7372f36..31032407254d 100644
--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -178,7 +178,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 	state = drm_atomic_state_alloc(fb->dev);
 	if (!state) {
 		ret = -ENOMEM;
-		goto out;
+		goto out_drop_locks;
 	}
 	state->acquire_ctx = &ctx;
 
@@ -238,6 +238,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
 	kfree(rects);
 	drm_atomic_state_put(state);
 
+out_drop_locks:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] drm: fix null pointer dereference on null state pointer
  2018-12-22 13:00 ` Colin King
@ 2018-12-24 10:53   ` Daniel Vetter
  -1 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2018-12-24 10:53 UTC (permalink / raw)
  To: Colin King
  Cc: Rob Clark, Maarten Lankhorst, Maxime Ripard, Sean Paul,
	David Airlie, Daniel Vetter, dri-devel, kernel-janitors,
	linux-kernel

On Sat, Dec 22, 2018 at 01:00:46PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> In the case where state cannot be allocated, the current exit path via
> label 'out' will dereference the null state pointer when calling
> drm_atomic_state_put. Fix this by adding a new error exit label and
> jumping to this to avoid the drm_atomic_state_put.
> 
> Detected by CoverityScan, CID#1476034 ("Dereference after null check")
> 
> Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Looks correct to me, merged into drm-misc-next-fixes for 4.21.

Thanks, Daniel

> ---
>  drivers/gpu/drm/drm_damage_helper.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
> index d2a1c7372f36..31032407254d 100644
> --- a/drivers/gpu/drm/drm_damage_helper.c
> +++ b/drivers/gpu/drm/drm_damage_helper.c
> @@ -178,7 +178,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
>  	state = drm_atomic_state_alloc(fb->dev);
>  	if (!state) {
>  		ret = -ENOMEM;
> -		goto out;
> +		goto out_drop_locks;
>  	}
>  	state->acquire_ctx = &ctx;
>  
> @@ -238,6 +238,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
>  	kfree(rects);
>  	drm_atomic_state_put(state);
>  
> +out_drop_locks:
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
>  
> -- 
> 2.19.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] drm: fix null pointer dereference on null state pointer
@ 2018-12-24 10:53   ` Daniel Vetter
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2018-12-24 10:53 UTC (permalink / raw)
  To: Colin King
  Cc: Rob Clark, Maarten Lankhorst, Maxime Ripard, Sean Paul,
	David Airlie, Daniel Vetter, dri-devel, kernel-janitors,
	linux-kernel

On Sat, Dec 22, 2018 at 01:00:46PM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> In the case where state cannot be allocated, the current exit path via
> label 'out' will dereference the null state pointer when calling
> drm_atomic_state_put. Fix this by adding a new error exit label and
> jumping to this to avoid the drm_atomic_state_put.
> 
> Detected by CoverityScan, CID#1476034 ("Dereference after null check")
> 
> Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Looks correct to me, merged into drm-misc-next-fixes for 4.21.

Thanks, Daniel

> ---
>  drivers/gpu/drm/drm_damage_helper.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
> index d2a1c7372f36..31032407254d 100644
> --- a/drivers/gpu/drm/drm_damage_helper.c
> +++ b/drivers/gpu/drm/drm_damage_helper.c
> @@ -178,7 +178,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
>  	state = drm_atomic_state_alloc(fb->dev);
>  	if (!state) {
>  		ret = -ENOMEM;
> -		goto out;
> +		goto out_drop_locks;
>  	}
>  	state->acquire_ctx = &ctx;
>  
> @@ -238,6 +238,7 @@ int drm_atomic_helper_dirtyfb(struct drm_framebuffer *fb,
>  	kfree(rects);
>  	drm_atomic_state_put(state);
>  
> +out_drop_locks:
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
>  
> -- 
> 2.19.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-24 10:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 13:00 [PATCH][next] drm: fix null pointer dereference on null state pointer Colin King
2018-12-22 13:00 ` Colin King
2018-12-24 10:53 ` Daniel Vetter
2018-12-24 10:53   ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.