Commit 19032628 authored by Kunwu Chan's avatar Kunwu Chan Committed by Alex Williamson
Browse files

vfio/pci: WARN_ON driver_override kasprintf failure



kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.

This is a blocking notifier callback, so errno isn't a proper return
value. Use WARN_ON to small allocation failures.

Signed-off-by: default avatarKunwu Chan <chentao@kylinos.cn>
Link: https://lore.kernel.org/r/20240115063434.20278-1-chentao@kylinos.cn


Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent b401b621
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2047,6 +2047,7 @@ static int vfio_pci_bus_notifier(struct notifier_block *nb,
			 pci_name(pdev));
		pdev->driver_override = kasprintf(GFP_KERNEL, "%s",
						  vdev->vdev.ops->name);
		WARN_ON(!pdev->driver_override);
	} else if (action == BUS_NOTIFY_BOUND_DRIVER &&
		   pdev->is_virtfn && physfn == vdev->pdev) {
		struct pci_driver *drv = pci_dev_driver(pdev);