Commit 61dbbedc authored by Alex Williamson's avatar Alex Williamson Committed by Peng Zhang
Browse files

vfio/pci: Restore zero affected bus reset devices warning

mainline inclusion
from mainline-v6.10-rc1
commit cbb325e77fbe62a06184175aa98c9eb98736c3e8
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAD6H2

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cbb325e77fbe62a06184175aa98c9eb98736c3e8



---------------------------------------------------------

Yi notes relative to commit f6944d4a0b87 ("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 b56b7aab ("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: default avatarYi Liu <yi.l.liu@intel.com>
Reviewed-by: default avatarCédric Le Goater <clg@redhat.com>
Reviewed-by: default avatarYi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20240516174831.2257970-1-alex.williamson@redhat.com


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent 5784d7a9
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1281,6 +1281,9 @@ static int vfio_pci_ioctl_get_pci_hot_reset_info(
	if (ret)
		return ret;

	if (WARN_ON(!count)) /* Should always be at least one */
		return -ERANGE;

	if (count > (hdr.argsz - sizeof(hdr)) / sizeof(*devices)) {
		hdr.count = count;
		ret = -ENOSPC;