dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Clear e after kfree in drm_mode_page_flip_ioctl
@ 2017-03-30 13:32 Daniel Vetter
  2017-03-30 14:26 ` Harry Wentland
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2017-03-30 13:32 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Intel Graphics Development, Julia Lawall,
	Daniel Vetter, Harry Wentland

With the explicit retry loop static analyzers get confused by the
control flow and believe that e could be accessed after kfree. That's
not possible, but it's non-obvious, so let's clear it to NULL.

We already cleared e = NULL at the top of the function, so this is all
in line.

Cc: Julia Lawall <julia.lawall@lip6.fr>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Fixes: 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_plane.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index ec62221d64a9..3a6de27bafed 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -922,6 +922,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
 		if (ret) {
 			kfree(e);
+			e = NULL;
 			goto out;
 		}
 	}
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm: Clear e after kfree in drm_mode_page_flip_ioctl
  2017-03-30 13:32 [PATCH] drm: Clear e after kfree in drm_mode_page_flip_ioctl Daniel Vetter
@ 2017-03-30 14:26 ` Harry Wentland
  2017-03-30 18:23   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Harry Wentland @ 2017-03-30 14:26 UTC (permalink / raw)
  To: Daniel Vetter, DRI Development
  Cc: Julia Lawall, Intel Graphics Development, Daniel Vetter

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

On 2017-03-30 09:32 AM, Daniel Vetter wrote:
> With the explicit retry loop static analyzers get confused by the
> control flow and believe that e could be accessed after kfree. That's
> not possible, but it's non-obvious, so let's clear it to NULL.
>
> We already cleared e = NULL at the top of the function, so this is all
> in line.
>
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Reported-by: Julia Lawall <julia.lawall@lip6.fr>
> Fixes: 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>   drivers/gpu/drm/drm_plane.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> index ec62221d64a9..3a6de27bafed 100644
> --- a/drivers/gpu/drm/drm_plane.c
> +++ b/drivers/gpu/drm/drm_plane.c
> @@ -922,6 +922,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
>   		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
>   		if (ret) {
>   			kfree(e);
> +			e = NULL;
>   			goto out;
>   		}
>   	}

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

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

* Re: [PATCH] drm: Clear e after kfree in drm_mode_page_flip_ioctl
  2017-03-30 14:26 ` Harry Wentland
@ 2017-03-30 18:23   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2017-03-30 18:23 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Daniel Vetter, Intel Graphics Development, Julia Lawall,
	DRI Development, Daniel Vetter

On Thu, Mar 30, 2017 at 10:26:24AM -0400, Harry Wentland wrote:
> Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Thanks for the quick review, pushed to drm-misc.
-Daniel

> 
> On 2017-03-30 09:32 AM, Daniel Vetter wrote:
> > With the explicit retry loop static analyzers get confused by the
> > control flow and believe that e could be accessed after kfree. That's
> > not possible, but it's non-obvious, so let's clear it to NULL.
> > 
> > We already cleared e = NULL at the top of the function, so this is all
> > in line.
> > 
> > Cc: Julia Lawall <julia.lawall@lip6.fr>
> > Reported-by: Julia Lawall <julia.lawall@lip6.fr>
> > Fixes: 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
> > Cc: Harry Wentland <harry.wentland@amd.com>
> > Cc: Daniel Vetter <daniel.vetter@intel.com>
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Sean Paul <seanpaul@chromium.org>
> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >   drivers/gpu/drm/drm_plane.c | 1 +
> >   1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
> > index ec62221d64a9..3a6de27bafed 100644
> > --- a/drivers/gpu/drm/drm_plane.c
> > +++ b/drivers/gpu/drm/drm_plane.c
> > @@ -922,6 +922,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
> >   		ret = drm_event_reserve_init(dev, file_priv, &e->base, &e->event.base);
> >   		if (ret) {
> >   			kfree(e);
> > +			e = NULL;
> >   			goto out;
> >   		}
> >   	}
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-03-30 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-30 13:32 [PATCH] drm: Clear e after kfree in drm_mode_page_flip_ioctl Daniel Vetter
2017-03-30 14:26 ` Harry Wentland
2017-03-30 18:23   ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).