Skip to content

Commit 9622b90

Browse files
committed
cpuinfo: show error when image is missing
The `criu cpuinfo check` command calls cpu_validate_cpuinfo(), which attempts to open the cpuinfo.img file using `open_image()`. If the image file is not found, `open_image()` returns an "empty image" object. As a result, `cpu_validate_cpuinfo()` tries to read from it and fails with the following error: (00.002473) Error (criu/protobuf.c:72): Unexpected EOF on (empty-image) This patch adds a check for an empty image and appropriate error message. Signed-off-by: Radostin Stoyanov <[email protected]>
1 parent 6eb5bb0 commit 9622b90

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

criu/arch/ppc64/cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ int cpu_validate_cpuinfo(void)
6464
if (!img)
6565
return -1;
6666

67+
if (empty_image(img)) {
68+
pr_err("No cpuinfo image\n");
69+
close_image(img);
70+
return -1;
71+
}
72+
6773
if (pb_read_one(img, &cpu_info, PB_CPUINFO) < 0)
6874
goto error;
6975

criu/arch/s390/cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ int cpu_validate_cpuinfo(void)
8787
if (!img)
8888
return -1;
8989

90+
if (empty_image(img)) {
91+
pr_err("No cpuinfo image\n");
92+
close_image(img);
93+
return -1;
94+
}
95+
9096
ret = 0;
9197
if (pb_read_one(img, &cpu_info, PB_CPUINFO) < 0)
9298
goto error;

criu/arch/x86/cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,12 @@ int cpu_validate_cpuinfo(void)
407407
if (!img)
408408
return -1;
409409

410+
if (empty_image(img)) {
411+
pr_err("No cpuinfo image\n");
412+
close_image(img);
413+
return -1;
414+
}
415+
410416
if (pb_read_one(img, &img_cpu_info, PB_CPUINFO) < 0)
411417
goto err;
412418

0 commit comments

Comments
 (0)