From aa44721fe8cab6aedb7149a3850eb699d406abc2 Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Fri, 13 Dec 2024 13:08:24 -0600 Subject: [PATCH] sahara: Avoid closing invalid fd In the event that no ramdump_path is provided to sahara_run() the ramdump_dir will remain -1. For good hygiene avoid calling close() on this invalid file descriptor. Signed-off-by: Bjorn Andersson --- sahara.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sahara.c b/sahara.c index bf04bc7..1e06303 100644 --- a/sahara.c +++ b/sahara.c @@ -492,7 +492,8 @@ int sahara_run(struct qdl_device *qdl, char *img_arr[], bool single_image, } } - close(ramdump_dir); + if (ramdump_dir >= 0) + close(ramdump_dir); return done ? 0 : -1; }