All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: fix the usage after free
@ 2015-08-24  3:56 Jammy Zhou
  2015-08-24  7:51 ` Christian König
  0 siblings, 1 reply; 7+ messages in thread
From: Jammy Zhou @ 2015-08-24  3:56 UTC (permalink / raw)
  To: dri-devel, master.homer

From: Mathias Tillman <master.homer@gmail.com>

For readdir_r(), the next directory entry is returned in caller-allocted
buffer (pointered by pent here).

https://bugs.freedesktop.org/show_bug.cgi?id=91704

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
---
 xf86drm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xf86drm.c b/xf86drm.c
index 5e02969..a7cc643 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2803,11 +2803,12 @@ static char *drmGetMinorNameForFD(int fd, int type)
 
 	while (readdir_r(sysdir, pent, &ent) == 0 && ent != NULL) {
 		if (strncmp(ent->d_name, name, len) == 0) {
+			snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
+				 ent->d_name);
+
 			free(pent);
 			closedir(sysdir);
 
-			snprintf(dev_name, sizeof(dev_name), DRM_DIR_NAME "/%s",
-				 ent->d_name);
 			return strdup(dev_name);
 		}
 	}
-- 
1.9.1

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

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

end of thread, other threads:[~2015-08-24 14:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  3:56 [PATCH] drm: fix the usage after free Jammy Zhou
2015-08-24  7:51 ` Christian König
2015-08-24  7:59   ` Zhou, Jammy
2015-08-24  8:03     ` Mathias Tillman
2015-08-24  8:20       ` Christian König
2015-08-24  8:28         ` Mathias Tillman
2015-08-24 14:30         ` Emil Velikov

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.