Skip to content

Commit 879635c

Browse files
committed
Unmap MMIO when registration fails
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
1 parent 178a285 commit 879635c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/mmio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ static ocxl_err global_mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t f
164164
ocxl_err rc = register_mmio(afu, addr, size, OCXL_GLOBAL_MMIO, &mmio_region);
165165
if (rc != OCXL_OK) {
166166
errmsg(afu, rc, "Could not register global MMIO region");
167+
munmap(addr, size);
167168
return rc;
168169
}
169170

@@ -177,7 +178,7 @@ static ocxl_err global_mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t f
177178
*
178179
* Map the per-PASID MMIO area of an AFU to memory.
179180
*
180-
* Map the per-PASID MMIO area of afu to the current process memory. The size and
181+
* Map the per-PASID MMIO area of AFU to the current process memory. The size and
181182
* contents of this area are specific each AFU. The size can be discovered with
182183
* ocxl_mmio_size().
183184
*
@@ -226,6 +227,7 @@ static ocxl_err mmio_map(ocxl_afu *afu, size_t size, int prot, uint64_t flags, o
226227
ocxl_err rc = register_mmio(afu, addr, size, OCXL_PER_PASID_MMIO, &mmio_region);
227228
if (rc != OCXL_OK) {
228229
errmsg(afu, rc, "Could not register global MMIO region", afu->identifier.afu_name);
230+
munmap(addr, size);
229231
return rc;
230232
}
231233

0 commit comments

Comments
 (0)