From 037c9ac7e9d3eaa072ae1edaad2bc22e18f4333a Mon Sep 17 00:00:00 2001
From: jiang-dawei15 <jiangdawei15@huawei.com>
Date: Thu, 5 May 2022 10:39:47 +0800
Subject: [PATCH] libcare-dump:change the return value

---
 src/libcare-dump.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/libcare-dump.c b/src/libcare-dump.c
index 8736452..b712709 100644
--- a/src/libcare-dump.c
+++ b/src/libcare-dump.c
@@ -45,6 +45,7 @@ void usage()
 
 int kpatch_dump_kpatch_header(const char *input_file)
 {
+    int rv;
     int fdi = -1;
     int ret = -1;
     int elf_size;
@@ -67,7 +68,12 @@ int kpatch_dump_kpatch_header(const char *input_file)
         goto cleanup;
     }
 
-    ret = read(fdi, &kp, sizeof(struct kpatch_file));
+    rv = read(fdi, &kp, sizeof(struct kpatch_file));
+    if (rv <= 0) {
+        printf("Read kpatch file '%s' failed.\n", input_file);
+        goto cleanup;
+    }
+    ret = 0;
     printf("%-25s %s\n", "Patch Name:", input_file);
     printf("%-25s %s\n", "Magic:", kp.magic);
     printf("%-25s %s\n", "Patch id:", kp.id);
-- 
2.27.0

