[dm-devel] [PATCH 28/39] kpartx: Handle errors from lseek()
Hannes Reinecke
hare at suse.de
Thu Jun 16 09:47:34 UTC 2016
Found by coverity.
Signed-off-by: Hannes Reinecke <hare at suse.com>
---
kpartx/gpt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kpartx/gpt.c b/kpartx/gpt.c
index 5a54970..3dac605 100644
--- a/kpartx/gpt.c
+++ b/kpartx/gpt.c
@@ -206,9 +206,10 @@ read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
int sector_size = get_sector_size(fd);
off_t offset = lba * sector_size;
uint64_t lastlba;
- ssize_t bytesread;
+ ssize_t bytesread;
- lseek(fd, offset, SEEK_SET);
+ if (lseek(fd, offset, SEEK_SET) < 0)
+ return 0;
bytesread = read(fd, buffer, bytes);
lastlba = last_lba(fd);
--
2.6.6
More information about the dm-devel
mailing list