R128SetupConnectors: avoid memory leak in error path

Reported by Oracle Parfait 16.2 static analyzer:

Error: Memory leak
   Memory leak [memory-leak]:
      Memory leak of pointer r128_output allocated with XNFcallocarray(1, 56)
        at line 558 of driver/xf86-video-r128/src/r128_output.c in function 'R128SetupConnectors'.
        calloc called at line 35 of xserver/os/alloc.c in function 'XNFcallocarray'
        Allocated value returned to caller at line 39
          r128_output allocated at line 543 of driver/xf86-video-r128/src/r128_output.c in function 'R128SetupConnectors' with XNFcallocarray(1, 56)
          r128_output leaks when output == NULL at line 558

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/driver/xf86-video-r128/-/merge_requests/20>
This commit is contained in:
Alan Coopersmith
2025-08-31 14:06:59 -07:00
parent 7d1c885bef
commit 524f48c4f7

View File

@@ -555,7 +555,10 @@ Bool R128SetupConnectors(ScrnInfoPtr pScrn)
output = R128OutputCreate(pScrn, "DVI-%d", --num_dvi);
}
if (!output) return FALSE;
if (!output) {
free(r128_output);
return FALSE;
}
output->interlaceAllowed = TRUE;
output->doubleScanAllowed = TRUE;
output->driver_private = r128_output;