unix/modmachine: Handle repeated /dev/mem open errors.
If opening of /dev/mem has failed an `OSError` is appropriately raised, but the next time `mem8/16/32` is accessed the invalid file descriptor is used and the program gets a SIGSEGV.
This commit is contained in:
parent
812969d615
commit
66f0afc91d
@ -57,10 +57,11 @@ uintptr_t mod_machine_mem_get_addr(mp_obj_t addr_o, uint align) {
|
||||
static uintptr_t last_base = (uintptr_t)-1;
|
||||
static uintptr_t map_page;
|
||||
if (!fd) {
|
||||
fd = open("/dev/mem", O_RDWR | O_SYNC);
|
||||
if (fd == -1) {
|
||||
int _fd = open("/dev/mem", O_RDWR | O_SYNC);
|
||||
if (_fd == -1) {
|
||||
mp_raise_OSError(errno);
|
||||
}
|
||||
fd = _fd;
|
||||
}
|
||||
|
||||
uintptr_t cur_base = addr & ~MICROPY_PAGE_MASK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user