disk/virtual: Fix use after free

Pointed out by cppcheck.

Change-Id: I785b7ee5623ac9fb37f2be0b9a75cdd82b5784fa
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7257
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Murai Takashi 2023-11-29 20:46:12 +09:00 committed by Fredrik Holmqvist
parent 4c07199d82
commit 8a0910dd49

View File

@ -558,9 +558,10 @@ virtio_block_init_driver(device_node *node, void **cookie)
B_ANY_KERNEL_BLOCK_ADDRESS, B_PAGE_SIZE,
B_FULL_LOCK, B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA);
if (info->bufferArea < B_OK) {
status_t status = info->bufferArea;
delete info->dma_resource;
free(info);
return info->bufferArea;
return status;
}
physical_entry entry;