dri: Fix memory leak.
The string gets allocated in libdrm with strdup so it is the callers responsibility to free. While at it, also add a proper NULL check, as NULL can be returned (e.g. when the file doesn't exist in a container). Found by inspection. BUG=none TEST=compile and confirm the UI still starts on Zork. Change-Id: Ib8701f7a15f030458885eade0effe5c8fe09dc83 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3017875 Tested-by: Bas Nieuwenhuizen <basni@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Chad Versace <chadversary@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
d3a73ff06d
commit
03af6f6b13
1 changed files with 5 additions and 1 deletions
6
dri.c
6
dri.c
|
|
@ -196,8 +196,12 @@ int dri_init(struct driver *drv, const char *dri_so_path, const char *driver_suf
|
|||
const __DRIextension *loader_extensions[] = { NULL };
|
||||
|
||||
struct dri_driver *dri = drv->priv;
|
||||
char *node_name = drmGetRenderDeviceNameFromFd(drv_get_fd(drv));
|
||||
if (!node_name)
|
||||
return -ENODEV;
|
||||
|
||||
dri->fd = open(drmGetRenderDeviceNameFromFd(drv_get_fd(drv)), O_RDWR);
|
||||
dri->fd = open(node_name, O_RDWR);
|
||||
free(node_name);
|
||||
if (dri->fd < 0)
|
||||
return -ENODEV;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue