]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
virtio-blk: fix memory leak on vring page allocation failure
authorTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 01:45:05 +0000 (22:45 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 11 Jun 2026 01:45:05 +0000 (22:45 -0300)
commit435e37b3141afbccd6d1907c58ae32f3d10f5fa2
tree4c0407c4b9d0468e113a26e527be0b90f7cd2b39
parent6f21a0ae17048c66f1fdcf50333672afa92f7ef4
virtio-blk: fix memory leak on vring page allocation failure

Bug: If pmm_alloc_page() failed in the middle of the vring page
allocation loop, previously allocated physical pages and the VA range
were not freed, causing a memory leak.

Fix: Add rollback loop on allocation failure to:
1. Unmap and free previously allocated physical pages
2. Free the VA range via kva_free_pages()

This is a pre-existing bug that was exposed during H6 regression
analysis, not a regression introduced by H6.

Test: make test-battery PASS (157/157), make analyzer PASS
src/drivers/virtio_blk.c