diff mbox series

[libubootenv,6/6] Fix coverity #293501

Message ID 20200628151336.952051-6-sbabic@denx.de
State Accepted
Headers show
Series [libubootenv,1/6] Add coverity setup for Travis | expand

Commit Message

Stefano Babic June 28, 2020, 3:13 p.m. UTC
Double close: caller of mtdread() is responsible to close the file
descriptor, remove close() calls from mtdread.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 src/uboot_env.c | 3 ---
 1 file changed, 3 deletions(-)
diff mbox series

Patch

diff --git a/src/uboot_env.c b/src/uboot_env.c
index 64d7aca..637b61d 100644
--- a/src/uboot_env.c
+++ b/src/uboot_env.c
@@ -442,7 +442,6 @@  static int mtdread(struct uboot_flash_env *dev, void *data)
 		while (count > 0) {
 			skip = is_nand_badblock(dev, start);
 			if (skip < 0) {
-				close(dev->fd);
 				return -EIO;
 			}
 
@@ -460,11 +459,9 @@  static int mtdread(struct uboot_flash_env *dev, void *data)
 				blocksize = count;
 
 			if (lseek(dev->fd, start, SEEK_SET) < 0) {
-				close(dev->fd);
 				return -EIO;
 			}
 			if (read(dev->fd, data, blocksize) != blocksize) {
-				close(dev->fd);
 				return -EIO;
 			}
 			start += dev->sectorsize;