sd: Avoid access to NULL BlockDriverState
PATCH 1/1 sd: Avoid access to NULL BlockDriverState
Commit 4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf (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.
--- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/sd/sd.c +1 -1
@@ -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 ; }
Signature · 1 line
1.8.1.4
Stefan Hajnoczi
AppliedQuoted 6 lines · Andreas Färber
Commit
4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf(blockdev: Remove IF_* check for read-onlyblockdev_init) added a usage ofbdrv_is_read_only()tosd_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.
Quoted 7 lines
Add a check to prevent this.
Suggested-by Kevin Wolf <[email protected]>Signed-off-by Andreas Färber <[email protected]>--- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block
Stefan