diff mbox series

[2/3] boot_handler: Check for openfileoutput() failure

Message ID 20210724150605.567038-3-festevam@gmail.com
State Accepted
Headers show
Series [1/3] stream_interface: Close the file descriptor on failure | expand

Commit Message

Fabio Estevam July 24, 2021, 3:06 p.m. UTC
openfileoutput() may fail, so check its return value and propagate
it in the case of failure.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 handlers/boot_handler.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/handlers/boot_handler.c b/handlers/boot_handler.c
index 4e14135cc0a7..e476c41db928 100644
--- a/handlers/boot_handler.c
+++ b/handlers/boot_handler.c
@@ -48,6 +48,8 @@  static int install_boot_environment(struct img_type *img,
 	ret = stat(filename, &statbuf);
 	if (ret) {
 		fdout = openfileoutput(filename);
+		if (fdout < 0)
+			return fdout;
 		ret = copyimage(&fdout, img, NULL);
 		close(fdout);
 	}