modesetting: avoid memory leak when ms_present_check_unflip() returns FALSE
Found by Oracle Parfait 13.3 static analyzer:
Memory leak [memory-leak]:
Memory leak of pointer event allocated with calloc(1, 16)
at line 470 of hw/xfree86/drivers/modesetting/present.c in
function 'ms_present_unflip'.
event allocated at line 431 with calloc(1, 16)
event leaks when ms_present_check_unflip(...) == 0 at line 438
and i >= config->num_crtc at line 445
Fixes: 13c7d53df
("modesetting: Implement page flipping support for Present.")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1730>
This commit is contained in:
parent
b65eea43dd
commit
bf63d9b34e
|
@ -424,22 +424,24 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id)
|
||||||
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
||||||
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
|
||||||
int i;
|
int i;
|
||||||
struct ms_present_vblank_event *event;
|
|
||||||
|
|
||||||
ms_present_set_screen_vrr(scrn, FALSE);
|
ms_present_set_screen_vrr(scrn, FALSE);
|
||||||
|
|
||||||
event = calloc(1, sizeof(struct ms_present_vblank_event));
|
if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL)) {
|
||||||
if (!event)
|
struct ms_present_vblank_event *event;
|
||||||
return;
|
|
||||||
|
|
||||||
event->event_id = event_id;
|
event = calloc(1, sizeof(struct ms_present_vblank_event));
|
||||||
event->unflip = TRUE;
|
if (!event)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL) &&
|
event->event_id = event_id;
|
||||||
ms_do_pageflip(screen, pixmap, event, NULL, FALSE,
|
event->unflip = TRUE;
|
||||||
ms_present_flip_handler, ms_present_flip_abort,
|
|
||||||
"Present-unflip")) {
|
if (ms_do_pageflip(screen, pixmap, event, NULL, FALSE,
|
||||||
return;
|
ms_present_flip_handler, ms_present_flip_abort,
|
||||||
|
"Present-unflip")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < config->num_crtc; i++) {
|
for (i = 0; i < config->num_crtc; i++) {
|
||||||
|
|
Loading…
Reference in New Issue