public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/atomic: fix null dereference
@ 2015-07-11 17:24 Sudip Mukherjee
  2015-07-11 18:17 ` Rob Clark
  0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee @ 2015-07-11 17:24 UTC (permalink / raw)
  To: David Airlie; +Cc: linux-kernel, dri-devel, Sudip Mukherjee

We are checking the size of e->event but we were doing it when e is
known to be NULL.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/gpu/drm/drm_atomic.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index acebd16..51d3a85 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1311,7 +1311,6 @@ static struct drm_pending_vblank_event *create_vblank_event(
 	e = kzalloc(sizeof *e, GFP_KERNEL);
 	if (e == NULL) {
 		spin_lock_irqsave(&dev->event_lock, flags);
-		file_priv->event_space += sizeof e->event;
 		spin_unlock_irqrestore(&dev->event_lock, flags);
 		goto out;
 	}
-- 
1.8.1.2


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

* Re: [PATCH] drm/atomic: fix null dereference
  2015-07-11 17:24 [PATCH] drm/atomic: fix null dereference Sudip Mukherjee
@ 2015-07-11 18:17 ` Rob Clark
  2015-07-12  6:14   ` Sudip Mukherjee
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Clark @ 2015-07-11 18:17 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: David Airlie, Linux Kernel Mailing List,
	dri-devel@lists.freedesktop.org

On Sat, Jul 11, 2015 at 1:24 PM, Sudip Mukherjee
<sudipm.mukherjee@gmail.com> wrote:
> We are checking the size of e->event but we were doing it when e is
> known to be NULL.

nak, this will leak event_space..  since it is a sizeof, it isn't
actually deref'ing e, but rather just using the static type info, so
it's ok (although perhaps funny looking)

BR,
-R


> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>  drivers/gpu/drm/drm_atomic.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index acebd16..51d3a85 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1311,7 +1311,6 @@ static struct drm_pending_vblank_event *create_vblank_event(
>         e = kzalloc(sizeof *e, GFP_KERNEL);
>         if (e == NULL) {
>                 spin_lock_irqsave(&dev->event_lock, flags);
> -               file_priv->event_space += sizeof e->event;
>                 spin_unlock_irqrestore(&dev->event_lock, flags);
>                 goto out;
>         }
> --
> 1.8.1.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/atomic: fix null dereference
  2015-07-11 18:17 ` Rob Clark
@ 2015-07-12  6:14   ` Sudip Mukherjee
  0 siblings, 0 replies; 3+ messages in thread
From: Sudip Mukherjee @ 2015-07-12  6:14 UTC (permalink / raw)
  To: Rob Clark
  Cc: David Airlie, Linux Kernel Mailing List,
	dri-devel@lists.freedesktop.org

On Sat, Jul 11, 2015 at 02:17:49PM -0400, Rob Clark wrote:
> On Sat, Jul 11, 2015 at 1:24 PM, Sudip Mukherjee
> <sudipm.mukherjee@gmail.com> wrote:
> > We are checking the size of e->event but we were doing it when e is
> > known to be NULL.
> 
> nak, this will leak event_space..  since it is a sizeof, it isn't
> actually deref'ing e, but rather just using the static type info, so
> it's ok (although perhaps funny looking)
Agreed, and I just verified the same with an userspace code also.
But i think this will confuse people like me who have started to look
at the drm code to start working with some new drm driver.
what about:
file_priv->event_space += sizeof(struct drm_event_vblank);

It will server the same purpose yet it will not be confusing.

regards
sudip

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

end of thread, other threads:[~2015-07-12  6:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-11 17:24 [PATCH] drm/atomic: fix null dereference Sudip Mukherjee
2015-07-11 18:17 ` Rob Clark
2015-07-12  6:14   ` Sudip Mukherjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox