Skip to contentSkip to conversation

vfio: check iommu_group_set_name() return value

PATCH Applied Liam Ni 4 participants 4 messages Jun 25, 2022 – Jun 30, 2022

Subsystems (2)
lore
Share & tools
lore

Liam Ni

author
#0 lore raw

PATCH 1/1 vfio: check iommu_group_set_name() return value

As iommu_group_set_name() can fail,we should check the return value.

---
 drivers/vfio/vfio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vfio/vfio.c +3 -1
index 61e71c1154be..ca823eeac237 100644
@@ -504,7 +504,9 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
 	if (IS_ERR(iommu_group))
 		return ERR_CAST(iommu_group);
 
-	iommu_group_set_name(iommu_group, "vfio-noiommu");
+	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
+	if (ret)
+		goto out_put_group;
 	ret = iommu_group_add_device(iommu_group, dev);
 	if (ret)
 		goto out_put_group;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines

From: Liam Ni <[email protected]>
Sent: Saturday, June 25, 2022 7:43 PM

As iommu_group_set_name() can fail,we should check the return value.

btw you probably also want to change other callers of this function for the same issue.

Quoted 22 lines
---
 drivers/vfio/vfio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/vfio/vfio.c +3 -1
index 61e71c1154be..ca823eeac237 100644
@@ -504,7 +504,9 @@ static struct vfio_group
 *vfio_noiommu_group_alloc(struct device *dev,
 	if (IS_ERR(iommu_group))
 		return ERR_CAST(iommu_group);
 
-	iommu_group_set_name(iommu_group, "vfio-noiommu");
+	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
+	if (ret)
+		goto out_put_group;
 	ret = iommu_group_add_device(iommu_group, dev);
 	if (ret)

goto out_put_group;
--
2.25.1

#3 lore raw
In reply to Liam Ni
Quoted 6 lines · On Sat, 25 Jun 2022 19:42:39 +0800 Liam Ni <[email protected]> wrote:

As iommu_group_set_name() can fail,we should check the return value.

---
 drivers/vfio/vfio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to vfio next branch for v5.20. Thanks,

Alex

Quoted 16 lines
drivers/vfio/vfio.c +3 -1
index 61e71c1154be..ca823eeac237 100644
@@ -504,7 +504,9 @@ static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
 	if (IS_ERR(iommu_group))
 		return ERR_CAST(iommu_group);
 
-	iommu_group_set_name(iommu_group, "vfio-noiommu");
+	ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
+	if (ret)
+		goto out_put_group;
 	ret = iommu_group_add_device(iommu_group, dev);
 	if (ret)
 		goto out_put_group;