提交 794cbc26 编写于 作者: A Andreas Färber 提交者: Stefan Hajnoczi

sd: Avoid access to NULL BlockDriverState

Commit 4f8a066b (blockdev: Remove IF_*
check for read-only blockdev_init) added a usage of bdrv_is_read_only()
to sd_init(), which is called for versatilepb, versatileab and
xilinx-zynq-a9 machines among others with NULL argument by default,
causing the new qom-test to fail.

Add a check to prevent this.
Suggested-by: NKevin Wolf <kwolf@redhat.com>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
上级 684b2544
......@@ -494,7 +494,7 @@ SDState *sd_init(BlockDriverState *bs, bool is_spi)
{
SDState *sd;
if (bdrv_is_read_only(bs)) {
if (bs && bdrv_is_read_only(bs)) {
fprintf(stderr, "sd_init: Cannot use read-only drive\n");
return NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册