]> git.ipfire.org Git - thirdparty/qemu.git/commit
qemu-coroutine-sleep: Silence Coverity warning
authorEric Blake <eblake@redhat.com>
Mon, 11 Nov 2019 20:35:24 +0000 (14:35 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 18 Nov 2019 22:01:34 +0000 (16:01 -0600)
commitf61ffad53f6d1cc4e23c557e22ed3d4f0ad0ae5e
treea4f9c119cfc2171b90f30cfec8d2489ba8851faf
parenta4d925f8f0634f72f1f03b23f0d172b7315e9ebf
qemu-coroutine-sleep: Silence Coverity warning

Coverity warns that we store the address of a stack variable through a
pointer passed in by the caller, which would let the caller trivially
trigger use-after-free if that stored value is still present when we
finish execution.  However, the way coroutines work is that after our
call to qemu_coroutine_yield(), control is temporarily continued in
the caller prior to our function concluding, and in order to resume
our coroutine, the caller must poll until the variable has been set to
NULL.  Thus, we can add an assert that we do not leak stack storage to
the caller on function exit.

Fixes: Coverity CID 1406474
CC: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20191111203524.21912-1-eblake@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
util/qemu-coroutine-sleep.c