Skip to content

Commit 6fb6b5c

Browse files
committed
Check for errors in mmio_read* before using the output value
Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
1 parent c99ec0f commit 6fb6b5c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/mmio.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ ocxl_err ocxl_mmio_read32(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, ui
619619
uint32_t val;
620620
ocxl_err ret = mmio_read32_native(mmio, offset, &val);
621621

622+
if (UNLIKELY(ret != OCXL_OK)) {
623+
return ret;
624+
}
625+
622626
switch (endian) {
623627
case OCXL_MMIO_BIG_ENDIAN:
624628
*out = be32toh(val);
@@ -632,7 +636,7 @@ ocxl_err ocxl_mmio_read32(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, ui
632636
break;
633637
}
634638

635-
return ret;
639+
return OCXL_OK;
636640
}
637641

638642
/**
@@ -659,6 +663,10 @@ ocxl_err ocxl_mmio_read64(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, ui
659663
uint64_t val;
660664
ocxl_err ret = mmio_read64_native(mmio, offset, &val);
661665

666+
if (UNLIKELY(ret != OCXL_OK)) {
667+
return ret;
668+
}
669+
662670
switch (endian) {
663671
case OCXL_MMIO_BIG_ENDIAN:
664672
*out = be64toh(val);
@@ -672,7 +680,7 @@ ocxl_err ocxl_mmio_read64(ocxl_mmio_h mmio, off_t offset, ocxl_endian endian, ui
672680
break;
673681
}
674682

675-
return ret;
683+
return OCXL_OK;
676684
}
677685

678686
/**

0 commit comments

Comments
 (0)