mirror of
https://github.com/vsergeev/c-periphery.git
synced 2026-08-21 05:59:36 +08:00
mmio: clear handle ptr on error to prevent spurious munmap() in mmio_close()
This commit is contained in:
@@ -80,6 +80,7 @@ int mmio_open(mmio_t *mmio, uintptr_t base, size_t size) {
|
||||
if (close(fd) < 0) {
|
||||
int errsv = errno;
|
||||
munmap(mmio->ptr, mmio->aligned_size);
|
||||
mmio->ptr = 0;
|
||||
return _mmio_error(mmio, MMIO_ERROR_OPEN, errsv, "Closing /dev/mem");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user