Skip to content

Commit

Permalink
Close fd once mmap succeeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jserv committed Jul 25, 2023
1 parent d36ccc5 commit 068b6ee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>

#include "device.h"
#include "riscv.h"
Expand Down Expand Up @@ -413,6 +414,7 @@ uint32_t *virtio_blk_init(virtio_blk_state_t *vblk, char *disk_file)
return NULL;
}
assert(!(((uintptr_t) disk_mem) & 0b11));
close(disk_fd);

vblk->disk = disk_mem;
vblk->capacity = (disk_size - 1) / DISK_BLK_SIZE + 1;
Expand Down

0 comments on commit 068b6ee

Please sign in to comment.