Skip to content

Commit 984c367

Browse files
committed
block/amend: Check whether the node exists
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: ced914d Signed-off-by: Max Reitz <[email protected]> Message-Id: <[email protected]> Reviewed-by: Maxim Levitsky <[email protected]>
1 parent 4215d34 commit 984c367

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

block/amend.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,12 @@ void qmp_x_blockdev_amend(const char *job_id,
6969
BlockdevAmendJob *s;
7070
const char *fmt = BlockdevDriver_str(options->driver);
7171
BlockDriver *drv = bdrv_find_format(fmt);
72-
BlockDriverState *bs = bdrv_find_node(node_name);
72+
BlockDriverState *bs;
7373

74+
bs = bdrv_lookup_bs(NULL, node_name, errp);
75+
if (!bs) {
76+
return;
77+
}
7478

7579
if (!drv) {
7680
error_setg(errp, "Block driver '%s' not found or not supported", fmt);

0 commit comments

Comments
 (0)