qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: "Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Eric Blake" <eblake@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"QEMU Trivial" <qemu-trivial@nongnu.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH for 2.10 27/35] syscall: fix dereference of undefined pointer
Date: Tue, 25 Jul 2017 09:25:44 +0200	[thread overview]
Message-ID: <069e3f18-317e-49d7-263f-206d5c21a755@vivier.eu> (raw)
In-Reply-To: <CAFEAcA86cuTukJ4HXVKDjewpxy2myPU1Gdbn671zqxJq6d09Wg@mail.gmail.com>

Le 24/07/2017 à 23:26, Peter Maydell a écrit :
> On 24 July 2017 at 19:27, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> Clang's scan-build-5.0 reports:
>>
>> linux-user/syscall.c:5581:9: warning: Dereference of undefined pointer value
>>     if (*host_rt_dev_ptr != 0) {
>>         ^~~~~~~~~~~~~~~~
>>
>> Reported-by: Clang Static Analyzer
>> Suggested-by: Laurent Vivier <lvivier@redhat.com>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  linux-user/syscall.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index fcd20fa276..e79b5baec4 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -5524,7 +5524,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp,
>>      int target_size;
>>      void *argptr;
>>      abi_ulong *target_rt_dev_ptr;
>> -    unsigned long *host_rt_dev_ptr;
>> +    unsigned long *host_rt_dev_ptr = NULL;
>>      abi_long ret;
>>      int i;
>>
>> @@ -5570,6 +5570,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp,
>>      unlock_user(argptr, arg, 0);
>>
>>      ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
>> +    assert(host_rt_dev_ptr);
> 
> There's not much point in this assert because it doesn't
> tell us anything we're not about to find out immediately
> by dereferencing the pointer...

It's just to shut off the warning.

What I said in the comment of the previous version of this patch:

I think we should "assert(host_rt_dev_ptr)" here. It's a bug if
host_rt_dev_ptr is not set.

The "for" loop scans the structure to find the rt_dev field, and we
should always enter in the first "if", so "host_rt_dev_ptr" is always set.

Thanks,
Laurent


  reply	other threads:[~2017-07-25  7:26 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 18:27 [Qemu-trivial] [PATCH for 2.10 00/35] fix bugs reported by Clang Static Analyzer Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 01/35] tests: add missing dependency to build QTEST_QEMU_BINARY Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 02/35] loader: check get_image_size() return value Philippe Mathieu-Daudé
2017-07-24 18:38   ` Eric Blake
2017-07-24 20:59     ` [Qemu-trivial] [Qemu-devel] " Alistair Francis
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 03/35] thunk: check nb_fields is valid before continuing Philippe Mathieu-Daudé
2017-07-24 18:37   ` Eric Blake
2017-07-26 22:48     ` Philippe Mathieu-Daudé
2017-07-24 21:16   ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 05/35] nbd: fix memory leak in nbd_opt_go() Philippe Mathieu-Daudé
2017-07-24 18:41   ` Eric Blake
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 06/35] qcow2: remove inconsistent check Philippe Mathieu-Daudé
2017-07-24 18:42   ` Eric Blake
2017-07-25 15:36     ` [Qemu-trivial] [Qemu-devel] " Paolo Bonzini
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 07/35] qcow2: fix null pointer dereference Philippe Mathieu-Daudé
2017-07-24 18:46   ` Eric Blake
2017-07-25  1:44     ` Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 08/35] " Philippe Mathieu-Daudé
2017-07-24 18:52   ` Eric Blake
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 09/35] ui/vnc: fix leak of SocketAddress ** Philippe Mathieu-Daudé
2017-07-25  8:37   ` [Qemu-trivial] [Qemu-devel] " Daniel P. Berrange
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 10/35] net/eth: fix incorrect check of iov_to_buf() return value Philippe Mathieu-Daudé
2017-07-26  9:51   ` Dmitry Fleytman
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 12/35] vfio/platform: fix use of freed memory Philippe Mathieu-Daudé
2017-07-25 15:37   ` [Qemu-trivial] [Qemu-devel] " Paolo Bonzini
2017-07-26 17:43   ` [Qemu-trivial] " Alex Williamson
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 13/35] vfio/pci: " Philippe Mathieu-Daudé
2017-07-25 15:38   ` [Qemu-trivial] [Qemu-devel] " Paolo Bonzini
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 14/35] vfio/ccw: fix incorrect malloc() size Philippe Mathieu-Daudé
2017-07-25  7:20   ` Cornelia Huck
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 15/35] usb: correctly handle Zero Length Packets Philippe Mathieu-Daudé
2018-05-29 14:22   ` Philippe Mathieu-Daudé
2018-05-30  6:16     ` Gerd Hoffmann
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 19/35] usb/dev-mtp: fix use of uninitialized variable Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 20/35] arm/boot: fix undefined instruction on secondary smp cpu bootloader Philippe Mathieu-Daudé
2017-07-24 21:06   ` Peter Maydell
2017-07-26 23:00     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 22/35] arm/vexpress: fix potential memory leak Philippe Mathieu-Daudé
2017-07-24 21:11   ` Peter Maydell
2017-07-24 21:45     ` Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 23/35] m68k/translate: fix incorrect copy/paste Philippe Mathieu-Daudé
2017-07-24 18:54   ` Laurent Vivier
2017-07-24 19:01     ` Richard Henderson
2017-07-24 19:19       ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
2017-07-24 19:20         ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 24/35] linux-user/sh4: fix incorrect memory write Philippe Mathieu-Daudé
2017-07-24 18:59   ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 25/35] linux-user: extract is_error() out of syscall.c Philippe Mathieu-Daudé
2017-07-24 19:14   ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 26/35] linux-user: use is_error() to avoid warnings and make the code clearer Philippe Mathieu-Daudé
2017-07-24 19:16   ` Laurent Vivier
2018-05-29 14:25     ` [Qemu-trivial] [Qemu-devel] " Philippe Mathieu-Daudé
2018-05-29 15:19       ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 27/35] syscall: fix dereference of undefined pointer Philippe Mathieu-Daudé
2017-07-24 19:33   ` Laurent Vivier
2017-07-25  5:34     ` Philippe Mathieu-Daudé
2017-07-24 21:26   ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2017-07-25  7:25     ` Laurent Vivier [this message]
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 29/35] syscall: fix out-of-bound memory access Philippe Mathieu-Daudé
2017-07-24 19:41   ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 30/35] syscall: fix use of uninitialized values Philippe Mathieu-Daudé
2017-07-24 19:51   ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 31/35] syscall: replace strcpy() by g_strlcpy() Philippe Mathieu-Daudé
2017-07-24 19:28   ` Laurent Vivier
2018-05-29 14:19     ` Philippe Mathieu-Daudé
2018-05-29 15:22       ` Laurent Vivier
2017-07-24 18:27 ` [Qemu-trivial] [PATCH for 2.10 32/35] timer/pxa2xx: silent warning about out-of-bound memory access Philippe Mathieu-Daudé
2017-07-24 21:01   ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2017-07-24 21:51     ` Philippe Mathieu-Daudé
2017-07-24 18:27 ` [Qemu-trivial] [RFC PATCH for 2.10 35/35] script to run docker image Philippe Mathieu-Daudé
2017-07-25 14:12   ` Alex Bennée
2017-07-25 14:41     ` Philippe Mathieu-Daudé
2017-07-25 15:03       ` Alex Bennée
2017-07-25 15:17         ` Philippe Mathieu-Daudé
2017-07-24 21:27 ` [Qemu-trivial] [PATCH for 2.10 00/35] fix bugs reported by Clang Static Analyzer Peter Maydell

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=069e3f18-317e-49d7-263f-206d5c21a755@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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).