From 50e6b20878cea96b7c4bc924c686ebee153874d5 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 23 Aug 2021 17:55:31 +0100 Subject: libfstools: handle open() return value properly in F2FS check Coverity CID: 1490101 Argument cannot be negative Signed-off-by: Daniel Golle --- libfstools/common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libfstools/common.c b/libfstools/common.c index f2d415d..c484776 100644 --- a/libfstools/common.c +++ b/libfstools/common.c @@ -90,8 +90,12 @@ static bool use_f2fs(struct volume *v, uint64_t offset, const char *bdev) int fd; fd = open(bdev, O_RDONLY); + if (fd < 0) + return false; + if (ioctl(fd, BLKGETSIZE64, &size) == 0) ret = size - offset > F2FS_MINSIZE; + close(fd); return ret; -- cgit v1.2.1