From: Matt Roper <matthew.d.roper@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Subject: [PATCH libdrm 1/2] xf86drm: Fix error handling for drmGetDevice()
Date: Fri, 16 Oct 2015 15:11:23 -0700 [thread overview]
Message-ID: <1445033484-21089-1-git-send-email-matthew.d.roper@intel.com> (raw)
Some of the error conditions in drmGetDevice() can lead to us calling
closedir(NULL) or leaking memory. Fix these conditions the same way we
did for drmGetDevices() in commit:
commit 8c4a1cbd98bd8d185d489395f33302a17db643a9
Author: Matt Roper <matthew.d.roper@intel.com>
Date: Wed Sep 30 09:30:51 2015 -0700
xf86drm: Fix error handling for drmGetDevices()
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
xf86drm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/xf86drm.c b/xf86drm.c
index a29db42..951edbb 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3108,7 +3108,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
sysdir = opendir(DRM_DIR_NAME);
if (!sysdir) {
ret = -errno;
- goto close_sysdir;
+ goto free_locals;
}
i = 0;
@@ -3165,16 +3165,16 @@ int drmGetDevice(int fd, drmDevicePtr *device)
for (i = 1; i < node_count && local_devices[i]; i++)
drmFreeDevice(&local_devices[i]);
- free(local_devices);
closedir(sysdir);
+ free(local_devices);
return 0;
free_devices:
drmFreeDevices(local_devices, i);
- free(local_devices);
-
-close_sysdir:
closedir(sysdir);
+
+free_locals:
+ free(local_devices);
return ret;
}
--
2.1.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2015-10-16 22:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 22:11 Matt Roper [this message]
2015-10-16 22:11 ` [PATCH libdrm 2/2] xf86drm: Handle unrecognized subsystems safely in drmGetDevice[s]() Matt Roper
2015-10-16 22:14 ` Alex Deucher
2015-10-16 22:27 ` Emil Velikov
2015-10-16 22:31 ` Matt Roper
2015-10-20 17:50 ` Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445033484-21089-1-git-send-email-matthew.d.roper@intel.com \
--to=matthew.d.roper@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox