mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-06 04:28:29 +02:00
drm: ensure drm_fd is closed if open fails
At the moment we open the drm fd right away, then proceed to check the terminal. If the terminal doesn't meet specs, we fail the open call but neglect to close the drm_fd. This commit fixes the code such that we don't leave the drm fd open inadvertently.
This commit is contained in:
parent
bf560986f0
commit
8aa3b01b33
1 changed files with 7 additions and 2 deletions
|
|
@ -145,6 +145,7 @@ static bool reset_scan_out_buffer_if_needed (ply_renderer_backend_t *backend,
|
|||
ply_renderer_head_t *head);
|
||||
static void flush_head (ply_renderer_backend_t *backend,
|
||||
ply_renderer_head_t *head);
|
||||
static void close_device (ply_renderer_backend_t *backend);
|
||||
|
||||
static bool
|
||||
ply_renderer_buffer_map (ply_renderer_backend_t *backend,
|
||||
|
|
@ -880,13 +881,13 @@ open_device (ply_renderer_backend_t *backend)
|
|||
|
||||
if (!ply_terminal_open (backend->terminal)) {
|
||||
ply_trace ("could not open terminal: %m");
|
||||
return false;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (!ply_terminal_is_vt (backend->terminal)) {
|
||||
ply_trace ("terminal is not a VT");
|
||||
ply_terminal_close (backend->terminal);
|
||||
return false;
|
||||
goto failed;
|
||||
}
|
||||
|
||||
ply_terminal_watch_for_active_vt_change (backend->terminal,
|
||||
|
|
@ -895,6 +896,10 @@ open_device (ply_renderer_backend_t *backend)
|
|||
backend);
|
||||
|
||||
return true;
|
||||
|
||||
failed:
|
||||
close_device (backend);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue