We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7629818 commit 71ba2adCopy full SHA for 71ba2ad
hw/block/fdc.c
@@ -1166,7 +1166,19 @@ static FDrive *get_drv(FDCtrl *fdctrl, int unit)
1166
1167
static FDrive *get_cur_drv(FDCtrl *fdctrl)
1168
{
1169
- return get_drv(fdctrl, fdctrl->cur_drv);
+ FDrive *cur_drv = get_drv(fdctrl, fdctrl->cur_drv);
1170
+
1171
+ if (!cur_drv->blk) {
1172
+ /*
1173
+ * Kludge: empty drive line selected. Create an anonymous
1174
+ * BlockBackend to avoid NULL deref with various BlockBackend
1175
+ * API calls within this model (CVE-2021-20196).
1176
+ * Due to the controller QOM model limitations, we don't
1177
+ * attach the created to the controller device.
1178
+ */
1179
+ cur_drv->blk = blk_create_empty_drive();
1180
+ }
1181
+ return cur_drv;
1182
}
1183
1184
/* Status A register : 0x00 (read-only) */
0 commit comments