From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [PULL 1/3] block/amend: Check whether the node exists
Date: Mon, 27 Jul 2020 16:38:10 +0200 [thread overview]
Message-ID: <20200727143812.1101547-2-mreitz@redhat.com> (raw)
In-Reply-To: <20200727143812.1101547-1-mreitz@redhat.com>
We should check whether the user-specified node-name actually refers to
a node. The simplest way to do that is to use bdrv_lookup_bs() instead
of bdrv_find_node() (the former wraps the latter, and produces an error
message if necessary).
Reported-by: Coverity (CID 1430268)
Fixes: ced914d0ab9fb2c900f873f6349a0b8eecd1fdbe
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200710095037.10885-1-mreitz@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
---
block/amend.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/block/amend.c b/block/amend.c
index f4612dcf08..392df9ef83 100644
--- a/block/amend.c
+++ b/block/amend.c
@@ -69,8 +69,12 @@ void qmp_x_blockdev_amend(const char *job_id,
BlockdevAmendJob *s;
const char *fmt = BlockdevDriver_str(options->driver);
BlockDriver *drv = bdrv_find_format(fmt);
- BlockDriverState *bs = bdrv_find_node(node_name);
+ BlockDriverState *bs;
+ bs = bdrv_lookup_bs(NULL, node_name, errp);
+ if (!bs) {
+ return;
+ }
if (!drv) {
error_setg(errp, "Block driver '%s' not found or not supported", fmt);
--
2.26.2
next prev parent reply other threads:[~2020-07-27 14:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 14:38 [PULL 0/3] Block patches for 5.1 Max Reitz
2020-07-27 14:38 ` Max Reitz [this message]
2020-07-27 14:38 ` [PULL 2/3] iotests: Select a default machine for the rx and avr targets Max Reitz
2020-07-27 14:38 ` [PULL 3/3] iotests/197: Fix for compat=0.10 Max Reitz
2020-07-28 10:19 ` [PULL 0/3] Block patches for 5.1 Peter Maydell
2020-07-28 16:12 ` Peter Maydell
2020-07-28 16:22 ` Thomas Huth
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=20200727143812.1101547-2-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--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).