[Qemu-devel] [PATCH] monitor: Fix gva2gpa coverityism

Dr. David Alan Gilbert (git) posted 1 patch 4 years, 10 months ago
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190510190140.17589-1-dgilbert@redhat.com
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Markus Armbruster <armbru@redhat.com>
monitor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] monitor: Fix gva2gpa coverityism
Posted by Dr. David Alan Gilbert (git) 4 years, 10 months ago
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Coverity is complaining that while I'm checking the return
value of mon_get_cpu(), I'm not actually using the checked value,
I'm calling it again and thus it's worried I might get null;
I don't think that's actually possible since i'm under
lock anyway.
However, it's a sensible cleanup.

CID: 1401346

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor.c b/monitor.c
index bb48997913..f93c4b5c76 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1685,7 +1685,7 @@ static void hmp_gva2gpa(Monitor *mon, const QDict *qdict)
         return;
     }
 
-    gpa  = cpu_get_phys_page_attrs_debug(mon_get_cpu(),
+    gpa  = cpu_get_phys_page_attrs_debug(cs,
                                          addr & TARGET_PAGE_MASK, &attrs);
     if (gpa == -1) {
         monitor_printf(mon, "Unmapped\n");
-- 
2.21.0


Re: [Qemu-devel] [PATCH] monitor: Fix gva2gpa coverityism
Posted by Stefan Hajnoczi 4 years, 10 months ago
On Fri, May 10, 2019 at 08:01:40PM +0100, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Coverity is complaining that while I'm checking the return
> value of mon_get_cpu(), I'm not actually using the checked value,
> I'm calling it again and thus it's worried I might get null;
> I don't think that's actually possible since i'm under
> lock anyway.
> However, it's a sensible cleanup.
> 
> CID: 1401346
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  monitor.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>