Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/vc4: Fix a memory leak in hang state error path

When vc4_save_hang_state() encounters an early return condition, it
returns without freeing the previously allocated `kernel_state`,
leaking memory.

Add the missing kfree() calls by consolidating the early return paths
into a single place.

Fixes: 214613656b51 ("drm/vc4: Add an interface for capturing the GPU state after a hang.")
Reviewed-by: Melissa Wen <mwen@igalia.com>
Link: https://patch.msgid.link/20260330-vc4-misc-fixes-v1-3-92defc940a29@igalia.com
Signed-off-by: Maíra Canal <mcanal@igalia.com>

+10 -8
+10 -8
drivers/gpu/drm/vc4/vc4_gem.c
··· 171 171 spin_lock_irqsave(&vc4->job_lock, irqflags); 172 172 exec[0] = vc4_first_bin_job(vc4); 173 173 exec[1] = vc4_first_render_job(vc4); 174 - if (!exec[0] && !exec[1]) { 175 - spin_unlock_irqrestore(&vc4->job_lock, irqflags); 176 - return; 177 - } 174 + if (!exec[0] && !exec[1]) 175 + goto err_free_state; 178 176 179 177 /* Get the bos from both binner and renderer into hang state. */ 180 178 state->bo_count = 0; ··· 189 191 kernel_state->bo = kzalloc_objs(*kernel_state->bo, state->bo_count, 190 192 GFP_ATOMIC); 191 193 192 - if (!kernel_state->bo) { 193 - spin_unlock_irqrestore(&vc4->job_lock, irqflags); 194 - return; 195 - } 194 + if (!kernel_state->bo) 195 + goto err_free_state; 196 196 197 197 k = 0; 198 198 for (i = 0; i < 2; i++) { ··· 282 286 vc4->hang_state = kernel_state; 283 287 spin_unlock_irqrestore(&vc4->job_lock, irqflags); 284 288 } 289 + 290 + return; 291 + 292 + err_free_state: 293 + spin_unlock_irqrestore(&vc4->job_lock, irqflags); 294 + kfree(kernel_state); 285 295 } 286 296 287 297 static void