zink: initialize drm_fd to -1
authorJosé Expósito <jexposit@redhat.com>
Wed, 22 Nov 2023 11:48:47 +0000 (12:48 +0100)
committerEric Engestrom <eric@engestrom.ch>
Fri, 8 Dec 2023 11:09:30 +0000 (11:09 +0000)
commit0b95d1a0303795bf1820c3980e289d9ade58cb5a
tree06d4995e9f4418322cc4b99c45adbe5da2064695
parentaa7a34120edf1acd92739d72dccbaeba2946fa9d
zink: initialize drm_fd to -1

The `zink_internal_create_screen()` function initializes
`screen->drm_fd` to 0, a valid file descriptor value, via `rzalloc`.

If an error is found during initialization, the `zink_destroy_screen()`
function is invoked in the `fail` label and the `screen->drm_fd` is
closed because its value is 0 and `screen->drm_fd != -1` is checked.

Initialize `screen->drm_fd` to -1 to avoid this issue.

Resolves: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10191
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Signed-off-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26332>
(cherry picked from commit fff3fc45a0125b408ca8d4dbd48e5633d63ccc5a)
.pick_status.json
src/gallium/drivers/zink/zink_screen.c