qemu-e2k/hw/scsi
Zhao Liu d765ab2ad8 hw/scsi/vhost-scsi: Fix missing ERRP_GUARD() for error_prepend()
As the comment in qapi/error, passing @errp to error_prepend() requires
ERRP_GUARD():

* = Why, when and how to use ERRP_GUARD() =
*
* Without ERRP_GUARD(), use of the @errp parameter is restricted:
...
* - It should not be passed to error_prepend(), error_vprepend() or
*   error_append_hint(), because that doesn't work with &error_fatal.
* ERRP_GUARD() lifts these restrictions.
*
* To use ERRP_GUARD(), add it right at the beginning of the function.
* @errp can then be used without worrying about the argument being
* NULL or &error_fatal.

ERRP_GUARD() could avoid the case when @errp is &error_fatal, the user
can't see this additional information, because exit() happens in
error_setg earlier than information is added [1].

The vhost_scsi_realize() passes @errp to error_prepend(), and as a
VirtioDeviceClass.realize method, its @errp is from DeviceClass.realize
so that there is no guarantee that the @errp won't point to
@error_fatal.

To avoid the issue like [1] said, add missing ERRP_GUARD() at the
beginning of this function.

[1]: Issue description in the commit message of commit ae7c80a7bd
     ("error: New macro ERRP_GUARD()").

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <fam@euphon.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Message-ID: <20240311033822.3142585-18-zhao1.liu@linux.intel.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2024-03-12 11:45:34 +01:00
..
emulation.c
esp-pci.c hw/scsi/esp-pci: set DMA_STAT_BCMBLT when BLAST command issued 2024-01-19 12:28:59 +01:00
esp.c esp.c: add my copyright to the file 2024-02-13 19:37:28 +00:00
Kconfig
lsi53c895a.c trivial patches for 2024-03-09 2024-03-09 20:12:05 +00:00
megasas.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
meson.build
mfi.h
mpi.h
mptconfig.c
mptendian.c
mptsas.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
mptsas.h
scsi-bus.c scsi: Don't ignore most usb-storage properties 2024-02-07 15:25:13 +01:00
scsi-disk.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
scsi-generic.c scsi: don't lock AioContext in I/O code path 2023-12-21 22:49:27 +01:00
spapr_vscsi.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
srp.h
trace-events hw/scsi/lsi53c895a: add timer to scripts processing 2024-03-08 15:51:21 +01:00
trace.h
vhost-scsi-common.c vhost-user-scsi: support reconnect to backend 2023-10-22 05:18:17 -04:00
vhost-scsi.c hw/scsi/vhost-scsi: Fix missing ERRP_GUARD() for error_prepend() 2024-03-12 11:45:34 +01:00
vhost-user-scsi.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
viosrp.h
virtio-scsi-dataplane.c Rename "QEMU global mutex" to "BQL" in comments and docs 2024-01-08 10:45:43 -05:00
virtio-scsi.c virtio-scsi: Attach event vq notifier with no_poll 2024-02-07 21:50:32 +01:00
vmw_pvscsi.c hw/scsi: Constify VMState 2023-12-30 07:38:06 +11:00
vmw_pvscsi.h