Skip to contentSkip to conversation

drm/atomic: fix null dereference

PATCH NAK Sudip Mukherjee 2 participants 3 messages Jul 11, 2015 – Jul 12, 2015

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

PATCH 1/1 drm/atomic: fix null dereference

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

---
 drivers/gpu/drm/drm_atomic.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -1
index acebd16..51d3a85 100644
@@ -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;
 	}
Signature · 6 lines
1.8.1.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 2 lines · Sudip Mukherjee

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

Quoted 20 lines
---
 drivers/gpu/drm/drm_atomic.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -2
index acebd16..51d3a85 100644
@@ -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

Quoted 4 lines

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

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

#2 lore raw
Quoted 8 lines · Rob Clark
Quoted 2 lines · Sudip Mukherjee

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
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel