Skip to content

Commit e04d2d1

Browse files
bonkfemmericp
authored andcommitted
close pci resource fd (#20)
1 parent 02eafc8 commit e04d2d1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ uint8_t* pci_map_resource(const char* pci_addr) {
4848
int fd = check_err(open(path, O_RDWR), "open pci resource");
4949
struct stat stat;
5050
check_err(fstat(fd, &stat), "stat pci resource");
51-
return (uint8_t*) check_err(mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0), "mmap pci resource");
51+
uint8_t* hw = (uint8_t*) check_err(mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0), "mmap pci resource");
52+
check_err(close(fd), "close pci resource");
53+
return hw;
5254
}
5355

5456
int pci_open_resource(const char* pci_addr, const char* resource, int flags) {

0 commit comments

Comments
 (0)