Commit 315fbed
committed
plugin/amdgpu: fix resource leaks in drm dump error paths
Several error paths in amdgpu_plugin_drm_dump_file() leak
resources. The drmPrimeHandleToFD() and open_img_file() failures
use break instead of goto exit, which skips per-iteration cleanup
and lets the function continue dumping metadata with a stale ret
value. Replace break with proper resource cleanup and goto exit.
The vm_info_entries buffer is not freed when the ioctl or
allocate_vm_entries() calls fail after allocating it, and the
buffer from posix_memalign() is never freed after sdma_copy_bo(),
leaking memory on every loop iteration. Add the missing xfree()
calls.
Check the amdgpu_device_initialize() return value because h_dev
is undefined on failure. Move list_handles_entries cleanup into
the exit block because error paths that goto exit skip the
existing xfree() call after the loop. Add a NULL check before
free_e(rd) because rd allocation can fail before the struct is
initialized.
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>1 parent b518e76 commit 315fbed
1 file changed
+23
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| 356 | + | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| |||
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
| 375 | + | |
374 | 376 | | |
375 | 377 | | |
376 | 378 | | |
| |||
379 | 381 | | |
380 | 382 | | |
381 | 383 | | |
382 | | - | |
| 384 | + | |
| 385 | + | |
383 | 386 | | |
| 387 | + | |
384 | 388 | | |
385 | 389 | | |
386 | 390 | | |
| |||
393 | 397 | | |
394 | 398 | | |
395 | 399 | | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
396 | 405 | | |
397 | 406 | | |
398 | 407 | | |
399 | 408 | | |
400 | 409 | | |
401 | 410 | | |
402 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
406 | 417 | | |
407 | 418 | | |
408 | 419 | | |
409 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
410 | 424 | | |
411 | 425 | | |
412 | 426 | | |
| |||
424 | 438 | | |
425 | 439 | | |
426 | 440 | | |
| 441 | + | |
| 442 | + | |
427 | 443 | | |
428 | 444 | | |
429 | 445 | | |
| |||
436 | 452 | | |
437 | 453 | | |
438 | 454 | | |
439 | | - | |
440 | 455 | | |
441 | 456 | | |
442 | 457 | | |
| |||
471 | 486 | | |
472 | 487 | | |
473 | 488 | | |
474 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
475 | 492 | | |
476 | 493 | | |
477 | 494 | | |
| |||
0 commit comments