projects
/
qemu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5997fbd
)
target/i386: Clean up error cases for vmsr_read_thread_stat()
author
Anthony Harivel
<aharivel@redhat.com>
Fri, 26 Jul 2024 10:26:32 +0000
(12:26 +0200)
committer
Paolo Bonzini
<pbonzini@redhat.com>
Wed, 31 Jul 2024 11:13:31 +0000
(13:13 +0200)
Fix leaking memory of file handle in case of error
Erase unused "pid = -1"
Add clearer error_report
Should fix Coverity CID
1558557
.
Signed-off-by: Anthony Harivel <aharivel@redhat.com>
Link:
https://lore.kernel.org/r/20240726102632.1324432-3-aharivel@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/kvm/vmsr_energy.c
patch
|
blob
|
history
diff --git
a/target/i386/kvm/vmsr_energy.c
b/target/i386/kvm/vmsr_energy.c
index a1d78f2f2aee2e4aaff7b3fe29b25e98e00c8571..7e064c5aef30273daf6b9e9e5fbdcd9ef7a58392 100644
(file)
--- a/
target/i386/kvm/vmsr_energy.c
+++ b/
target/i386/kvm/vmsr_energy.c
@@
-270,7
+270,7
@@
void vmsr_read_thread_stat(pid_t pid,
FILE *file = fopen(path, "r");
if (file == NULL) {
-
pid = -1
;
+
error_report("Error opening %s", path_name)
;
return;
}
@@
-279,7
+279,8
@@
void vmsr_read_thread_stat(pid_t pid,
" %*u %*u %*u %*u %*u %*u %*u %*u %*u %*d %*u %*u %u",
utime, stime, cpu_id) != 3)
{
- pid = -1;
+ fclose(file);
+ error_report("Error fscanf did not report the right amount of items");
return;
}