diff options
author | Eric Blake <eblake@redhat.com> | 2019-07-19 12:20:01 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2019-07-19 13:19:18 -0500 |
commit | 5cf42b1c1f75499b467701926d3c9691d27712e1 (patch) | |
tree | dd0055f36f26ae0b5c6c16eb52a2f4977535471c /disas.c | |
parent | e2b47666fe1544959c89bd3ed159e9e37cc9fc73 (diff) | |
download | qemu-5cf42b1c1f75499b467701926d3c9691d27712e1.zip |
nbd: Initialize reply on failure
We've had two separate reports of different callers running into use
of uninitialized data if s->quit is set (one detected by gcc -O3,
another by valgrind), due to checking 'nbd_reply_is_simple(reply) ||
s->quit' in the wrong order. Rather than chasing down which callers
need to pre-initialize reply, and whether there are any other
uninitialized uses, it's easier to guarantee that reply will always be
set by nbd_co_receive_one_chunk() even on failure.
The uninitialized use happens to be harmless (the only time the
variable is uninitialized is if s->quit is set, so the conditional
results in the same action regardless of what was read from reply),
and was introduced in commit 65e01d47.
In fixing the problem, it can also be seen that all (one) callers pass
in a non-NULL reply, so there is a dead conditional to also be cleaned
up.
Reported-by: Thomas Huth <thuth@redhat.com>
Reported-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190719172001.19770-1-eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Diffstat (limited to 'disas.c')
0 files changed, 0 insertions, 0 deletions