nouveau: fix potential double-free in nouveau_drm_screen_create

Fixes: 821f4c8d99 ("nouveau: import libdrm_nouveau")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29000>
(cherry picked from commit d163498dbe)
This commit is contained in:
Karol Herbst 2024-05-01 11:16:57 +02:00 committed by Eric Engestrom
parent 27cf49205c
commit 02e295cb5c
2 changed files with 3 additions and 3 deletions

View file

@ -84,7 +84,7 @@
"description": "nouveau: fix potential double-free in nouveau_drm_screen_create",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "821f4c8d99a3068758db834a5c219082a9609b3c",
"notes": null

View file

@ -65,11 +65,11 @@ nouveau_drm_new(int fd, struct nouveau_drm **pdrm)
if (!drm)
return -ENOMEM;
drm->fd = fd;
*pdrm = drm;
drmVersionPtr ver = drmGetVersion(fd);
if (!ver)
goto out_err;
*pdrm = drm;
drm->version = (ver->version_major << 24) |
(ver->version_minor << 8) |
@ -81,7 +81,7 @@ nouveau_drm_new(int fd, struct nouveau_drm **pdrm)
return 0;
out_err:
nouveau_drm_del(&drm);
nouveau_drm_del(pdrm);
return -EINVAL;
}