diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-04-14 07:52:12 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-04-14 07:52:12 +0000 |
commit | ea727df30c63ebc7a02a4ed0ee1e62039086a0ed (patch) | |
tree | 60bba7a38b82ff9d5a50c59b2461c4e7ae89a3f4 /lib/libdrm/xf86drm.c | |
parent | 2af36c275c17ede3d2fa17cddc8e42509d4d801d (diff) |
Merge libdrm 2.4.79
Diffstat (limited to 'lib/libdrm/xf86drm.c')
-rw-r--r-- | lib/libdrm/xf86drm.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c index 7ab64022e..f43f6569c 100644 --- a/lib/libdrm/xf86drm.c +++ b/lib/libdrm/xf86drm.c @@ -1019,8 +1019,10 @@ char *drmGetBusid(int fd) if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL; u.unique = drmMalloc(u.unique_len + 1); - if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) + if (drmIoctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) { + drmFree(u.unique); return NULL; + } u.unique[u.unique_len] = '\0'; return u.unique; @@ -1548,14 +1550,12 @@ drm_context_t *drmGetReservedContextList(int fd, int *count) if (!(list = drmMalloc(res.count * sizeof(*list)))) return NULL; - if (!(retval = drmMalloc(res.count * sizeof(*retval)))) { - drmFree(list); - return NULL; - } + if (!(retval = drmMalloc(res.count * sizeof(*retval)))) + goto err_free_list; res.contexts = list; if (drmIoctl(fd, DRM_IOCTL_RES_CTX, &res)) - return NULL; + goto err_free_context; for (i = 0; i < res.count; i++) retval[i] = list[i].handle; @@ -1563,6 +1563,12 @@ drm_context_t *drmGetReservedContextList(int fd, int *count) *count = res.count; return retval; + +err_free_list: + drmFree(list); +err_free_context: + drmFree(retval); + return NULL; } void drmFreeReservedContextList(drm_context_t *pt) |