drm: fix the usage after free
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: Mathias Tillman <master.homer@gmail.com> Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>main
parent
1eba47a763
commit
5c42b5e36a
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue