From 5433c24f0f9306c82ad9bcc2b2b586e5f0ed8fa5 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 19 Oct 2015 17:53:29 +0200 Subject: block: Prepare for NULL BDS blk_bs() will not necessarily return a non-NULL value any more (unless blk_is_available() is true or it can be assumed to otherwise, e.g. because it is called immediately after a successful blk_new_with_bs() or blk_new_open()). Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- monitor.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'monitor.c') diff --git a/monitor.c b/monitor.c index 4f1ba2f666..301a143ffa 100644 --- a/monitor.c +++ b/monitor.c @@ -4145,6 +4145,10 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, monitor_printf(mon, "Device not found %s\n", device); return -1; } + if (!blk_bs(blk)) { + monitor_printf(mon, "Device '%s' has no medium\n", device); + return -1; + } bdrv_add_key(blk_bs(blk), NULL, &err); if (err) { -- cgit v1.2.3