From 9d29d4bef5eff173ca03c3a36bc5fc8b88004684 Mon Sep 17 00:00:00 2001 From: Kenneth Thompson Date: Tue, 3 Aug 2021 22:04:10 -0700 Subject: [PATCH] drivers/bch: Handle return value of bchlib_readsector() --- drivers/bch/bchlib_read.c | 12 ++++++++++-- drivers/bch/bchlib_write.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/bch/bchlib_read.c b/drivers/bch/bchlib_read.c index 9010a2171d..7c6b6239a8 100644 --- a/drivers/bch/bchlib_read.c +++ b/drivers/bch/bchlib_read.c @@ -99,7 +99,11 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, { /* Read the sector into the sector buffer */ - bchlib_readsector(bch, sector); + ret = bchlib_readsector(bch, sector); + if (ret < 0) + { + return ret; + } /* Copy the tail end of the sector to the user buffer */ @@ -169,7 +173,11 @@ ssize_t bchlib_read(FAR void *handle, FAR char *buffer, size_t offset, { /* Read the sector into the sector buffer */ - bchlib_readsector(bch, sector); + ret = bchlib_readsector(bch, sector); + if (ret < 0) + { + return ret; + } /* Copy the head end of the sector to the user buffer */ diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 0540e66f71..8944cae9d7 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -84,7 +84,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, { /* Read the full sector into the sector buffer */ - bchlib_readsector(bch, sector); + ret = bchlib_readsector(bch, sector); + if (ret < 0) + { + return ret; + } /* Copy the tail end of the sector from the user buffer */ @@ -166,7 +170,11 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, { /* Read the sector into the sector buffer */ - bchlib_readsector(bch, sector); + ret = bchlib_readsector(bch, sector); + if (ret < 0) + { + return ret; + } /* Copy the head end of the sector from the user buffer */