iommu/apple-dart: Properly check the error
Subsystems (2)
PATCH 1/1 iommu/apple-dart: Properly check the error
The apple_dart_device_group() function expects pci_device_group() (or generic_device_group() for a non-PCI device) to return NULL on failure. However, both of them return an error pointer instead of NULL. The error pointer then is immediately dereferenced by the iommu_group_get_iommudata() function.
Check for an error pointer instead of NULL and return the error.
Fixes f0b636804c7c ("iommu/dart: Clear sid2group entry when a group is freed")
Signed-off-by Anton Protopopov <[email protected]>
---
(Found accidentally, while working on BPF stuff.)
drivers/iommu/apple-dart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/apple-dart.c +2 -2
@@ -981,8 +981,8 @@ static struct iommu_group *apple_dart_device_group(struct device *dev)#endif group =generic_device_group (dev); - res =ERR_PTR (-ENOMEM ); -if (!group) + res = group; +if (IS_ERR (group)) goto out; group_master_cfg =iommu_group_get_iommudata (group);