]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: block: Allow NULL 'data' in 'qemuBlockStorageSourceChainDetach'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 16 Aug 2024 14:08:53 +0000 (16:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 21 Aug 2024 13:49:36 +0000 (15:49 +0200)
Some code paths, such as if hotplug of an empty cdrom fails can cause
that 'qemuBlockStorageSourceChainDetach' will be called with 'NULL'
@data as there is no backend for the disk.

The above case became possible once we allowed hotplug of cdroms and
subsequently fixed the case when users would hotplug an empty cdrom
which ultimately caused the possibility of having no backend in the
hotplug code path which was not possible before (see 'Fixes:' below and
also the commit linked from there).

Make 'qemuBlockStorageSourceChainDetach' tolerate NULL @data by simply
returning early.

Fixes: 894c6c5c1686cfbc1742493ed512a4795098b763
Resolves: https://issues.redhat.com/browse/RHEL-54550
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_block.c

index d6cdf521c4abfcd756b1a27e4adf0f20ce92fa2f..6e90bae9f21c026a623e41a2f3c1515da06a3d5b 100644 (file)
@@ -1927,6 +1927,9 @@ qemuBlockStorageSourceChainDetach(qemuMonitor *mon,
 {
     size_t i;
 
+    if (!data)
+        return;
+
     if (data->copyOnReadAttached)
         ignore_value(qemuMonitorBlockdevDel(mon, data->copyOnReadNodename));