Skip to contentSkip to conversation

iommu: check if group is NULL before remove device

PATCH New Frank Wunderlich 1 participant 1 message Jul 15, 2021 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: check if group is NULL before remove device

From: Frank Wunderlich <[email protected]>

if probe is failing, iommu_group may be not initialized, so freeing it will result in NULL pointer access

Fixes d72e31c93746 ("iommu: IOMMU Groups")
---
 drivers/iommu/iommu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/iommu.c +3 -0
index 5419c4b9f27a..63f0af10c403 100644
@@ -924,6 +924,9 @@ void iommu_group_remove_device(struct device *dev)
 	struct iommu_group *group = dev->iommu_group;
 	struct group_device *tmp_device, *device = NULL;
 
+	if (!group)
+		return;
+
 	dev_info(dev, "Removing from iommu group %d\n", group->id);
 
 	/* Pre-notify listeners that a device is being removed. */
Signature · 1 line
2.25.1