vpci: don't assume that vpci per-device data exists unconditionally
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 26 Oct 2022 12:55:30 +0000 (14:55 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 26 Oct 2022 12:55:30 +0000 (14:55 +0200)
commit6ccb5e308ceeb895fbccd87a528a8bd24325aa39
tree59d6a6d0454cd0e88eb30c51527e90181f97835a
parentef9cc669ba157f9e71fd79722ee43892e7304604
vpci: don't assume that vpci per-device data exists unconditionally

It's possible for a device to be assigned to a domain but have no
vpci structure if vpci_process_pending() failed and called
vpci_remove_device() as a result.  The unconditional accesses done by
vpci_{read,write}() and vpci_remove_device() to pdev->vpci would
then trigger a NULL pointer dereference.

Add checks for pdev->vpci presence in the affected functions.

Fixes: 9c244fdef7 ('vpci: add header handlers')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
xen/drivers/vpci/vpci.c