qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Akihiko Odaki <akihiko.odaki@gmail.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH] ui/gtk: fix NULL pointer dereference
Date: Mon, 08 Mar 2021 13:42:47 +0100	[thread overview]
Message-ID: <134602378.QJW5UkElOJ@silver> (raw)
In-Reply-To: <CAMVc7JXb=eK2FgEx0SV7N-DL65EaMPKHM9rZnHCfu5KTPin48g@mail.gmail.com>

On Montag, 8. März 2021 12:31:33 CET Akihiko Odaki wrote:
> 2021年3月8日(月) 19:39 Christian Schoenebeck <qemu_oss@crudebyte.com>:
> > This was just about silencing the mentioned automated Coverity defects
> > report. If you have a better solution, then just ignore this patch.
> > 
> > Best regards,
> > Christian Schoenebeck
> 
> I do not have an access to Coverity defects report. I'd appreciate the
> details if you provide one. I suspect I made a mistake somewhere else
> ui/gtk.c in c821a58ee7 ("ui/console: Pass placeholder surface to
> display").

Unfortunately Coverity's defects reports are not very verbose. In this case:

*** CID 1448421:    (FORWARD_NULL)
/qemu/ui/gtk.c: 570 in gd_switch()
564             surface_width(vc->gfx.ds) == surface_width(surface) &&
565             surface_height(vc->gfx.ds) == surface_height(surface)) {
566             resized = false;
567         }
568         vc->gfx.ds = surface;
569     
>>> CID 1448421:    (FORWARD_NULL)
>>> Dereferencing null pointer "surface".
570         if (surface->format == PIXMAN_x8r8g8b8) {
571             /*
572              * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24
573              *
574              * No need to convert, use surface directly.  Should be the
575              * common case as this is qemu_default_pixelformat(32) too.

So no detailed path is outlined that may lead to the detected situation (i.e. 
no call stack or conditions like you would get e.g. with clang's static 
analyzer).

There are false positives sometimes, but they should be silenced in some way.

So as you assume "surface" pointer should never be NULL, why did you remove 
the return statement in gd_switch() with c821a58ee7 then? Redundancy?

diff --git a/ui/gtk.c b/ui/gtk.c
index c32ee34edc..3edaf041de 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -567,10 +567,6 @@ static void gd_switch(DisplayChangeListener *dcl,
     }
     vc->gfx.ds = surface;
 
-    if (!surface) {
-        return;
-    }
-
     if (surface->format == PIXMAN_x8r8g8b8) {
         /*
          * PIXMAN_x8r8g8b8 == CAIRO_FORMAT_RGB24

I was reading your change as you wanted to reach the end of the function in 
case of surface == NULL.

Best regards,
Christian Schoenebeck




  reply	other threads:[~2021-03-08 13:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07 19:38 [PATCH] ui/gtk: fix NULL pointer dereference Christian Schoenebeck
2021-03-08  3:45 ` Akihiko Odaki
2021-03-08 10:39   ` Christian Schoenebeck
2021-03-08 11:31     ` Akihiko Odaki
2021-03-08 12:42       ` Christian Schoenebeck [this message]
2021-03-08 13:21         ` Akihiko Odaki
2021-03-08 13:37         ` Peter Maydell
2021-03-08 13:57           ` Akihiko Odaki
2021-03-08 14:03           ` Christian Schoenebeck
2021-03-08 14:17             ` Akihiko Odaki
2021-03-08 14:30               ` Philippe Mathieu-Daudé
2021-03-08 14:57                 ` Christian Schoenebeck
2021-03-09  4:20                   ` Akihiko Odaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=134602378.QJW5UkElOJ@silver \
    --to=qemu_oss@crudebyte.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).