]> exis.tech > repos - linux.git/commit
drm/vc4: fix krealloc() memory leak
authorAlexander A. Klimov <grandmaster@al2klimov.de>
Sat, 6 Jun 2026 12:38:10 +0000 (14:38 +0200)
committerMaíra Canal <mcanal@igalia.com>
Tue, 9 Jun 2026 18:29:57 +0000 (15:29 -0300)
commit5d563a5da8717629ae72f9eadf1e0e340bd1658b
treefa21660ed467b9d33e579e9ab404e0e83c424cb5
parentf329e8325e054bd6d84d10904f8dd51137281b92
drm/vc4: fix krealloc() memory leak

Don't just overwrite the original pointer passed to krealloc()
with its return value without checking latter:

    MEM = krealloc(MEM, SZ, GFP);

If krealloc() returns NULL, that erases the pointer
to the still allocated memory, hence leaks this memory.
Instead, use a temporary variable, check it's not NULL
and only then assign it to the original pointer:

    TMP = krealloc(MEM, SZ, GFP);
    if (!TMP) return;
    MEM = TMP;

While on it, use krealloc_array().

Fixes: 6d45c81d229d ("drm/vc4: Add support for branching in shader validation.")
Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Link: https://patch.msgid.link/20260606123817.37222-1-grandmaster@al2klimov.de
drivers/gpu/drm/vc4/vc4_validate_shaders.c