Skip to contentSkip to conversation

drm: Clear e after kfree in drm_mode_page_flip_ioctl

PATCH In review Daniel Vetter 4 participants 4 messages Mar 30, 2017

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

PATCH 1/1 drm: Clear e after kfree in drm_mode_page_flip_ioctl

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 <[email protected]>
Fixes 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
Cc Harry Wentland <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Sean Paul <[email protected]>
---
 drivers/gpu/drm/drm_plane.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_plane.c +1 -0
index ec62221d64a9..3a6de27bafed 100644
@@ -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;
 		}
 	}
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✓ Fi.CI.BAT: success for drm: Clear e after kfree in drm_mode_page_flip_ioctl

== Series Details ==

== Series Details ==

Series: drm: Clear e after kfree in drm_mode_page_flip_ioctl
URL : https://patchwork.freedesktop.org/series/22205/
State : success

== Summary ==

Series 22205v1 drm: Clear e after kfree in drm_mode_page_flip_ioctl
https://patchwork.freedesktop.org/api/1.0/series/22205/revisions/1/mbox/

Test kms_cursor_legacy:

        Subgroup basic-flip-before-cursor-legacy:
                pass       -> DMESG-WARN (fi-byt-n2820) fdo#100415

fdo#100415 https://bugs.freedesktop.org/show_bug.cgi?id=100415

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time: 431s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time: 425s
fi-bsw-n3050     total:278  pass:239  dwarn:0   dfail:0   fail:0   skip:39  time: 580s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time: 509s
fi-bxt-t5700     total:278  pass:258  dwarn:0   dfail:0   fail:0   skip:20  time: 557s
fi-byt-j1900     total:278  pass:251  dwarn:0   dfail:0   fail:0   skip:27  time: 487s
fi-byt-n2820     total:278  pass:246  dwarn:1   dfail:0   fail:0   skip:31  time: 484s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 410s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time: 412s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time: 419s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 492s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 491s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time: 456s
fi-kbl-7560u     total:278  pass:267  dwarn:1   dfail:0   fail:0   skip:10  time: 570s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 452s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time: 574s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time: 459s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time: 492s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time: 432s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time: 527s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time: 399s

263ea0ba874fe10b16d916d60587a62d2274b5c0 drm-tip: 2017y-03m-30d-13h-20m-32s UTC integration manifest f54f4fb drm: Clear e after kfree in drm_mode_page_flip_ioctl

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4361/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/1
#2 lore raw
In reply to Daniel Vetter
Quoted 24 lines · Daniel Vetter

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 <[email protected]>
Fixes 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
Cc Harry Wentland <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Sean Paul <[email protected]>
---
  drivers/gpu/drm/drm_plane.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_plane.c +0 -0
index ec62221d64a9..3a6de27bafed 100644

drivers/gpu/drm/drm_plane.c int drm_mode_page_flip_ioctl(struct drm_device *dev, · line 928

Quoted 7 lines
drivers/gpu/drm/drm_plane.c +1 -0
@@ -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
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 1 line · Harry Wentland

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

Quoted 34 lines · Daniel Vetter
Quoted 31 lines

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 <[email protected]>
Fixes 29dc0d1de182 ("drm: Roll out acquire context for the page_flip ioctl")
Cc Harry Wentland <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Sean Paul <[email protected]>
---
  drivers/gpu/drm/drm_plane.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_plane.c +1 -0
index ec62221d64a9..3a6de27bafed 100644
@@ -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;
  		}
  	}
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx