qemu: block: Allow NULL 'data' in 'qemuBlockStorageSourceChainDetach'

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: 894c6c5c16
Resolves: https://issues.redhat.com/browse/RHEL-54550
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Peter Krempa 2024-08-16 16:08:53 +02:00
parent 85e07fb1ce
commit 204013d4aa

View File

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