From: Daniel Golle Date: Mon, 23 Aug 2021 16:55:31 +0000 (+0100) Subject: libfstools: handle open() return value properly in F2FS check X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=50e6b20878cea96b7c4bc924c686ebee153874d5;p=project%2Ffstools.git libfstools: handle open() return value properly in F2FS check Coverity CID: 1490101 Argument cannot be negative Signed-off-by: Daniel Golle --- 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;