Skip to content

Commit cbb325e

Browse files
committed
vfio/pci: Restore zero affected bus reset devices warning
Yi notes relative to commit f6944d4 ("vfio/pci: Collect hot-reset devices to local buffer") that we previously tested the resulting device count with a WARN_ON, which was removed when we switched to the in-loop user copy in commit b56b7aa ("vfio/pci: Copy hot-reset device info to userspace in the devices loop"). Finding no devices in the bus/slot would be an unexpected condition, so let's restore the warning and trigger a -ERANGE error here as success with no devices would be an unexpected result to userspace as well. Suggested-by: Yi Liu <yi.l.liu@intel.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Link: https://lore.kernel.org/r/20240516174831.2257970-1-alex.williamson@redhat.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
1 parent dda057a commit cbb325e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,9 @@ static int vfio_pci_ioctl_get_pci_hot_reset_info(
12811281
if (ret)
12821282
return ret;
12831283

1284+
if (WARN_ON(!count)) /* Should always be at least one */
1285+
return -ERANGE;
1286+
12841287
if (count > (hdr.argsz - sizeof(hdr)) / sizeof(*devices)) {
12851288
hdr.count = count;
12861289
ret = -ENOSPC;

0 commit comments

Comments
 (0)