Thread (2 messages) flat view 2 messages, 2 authors, 2014-02-25

Re: [PATCHv2 02/16] iommu/omap: omap_iommu_attach() should return ENODEV, not NULL

From: Laurent Pinchart <hidden>
Date: 2014-02-25 21:13:00
Also in: linux-arm-kernel, linux-iommu, linux-omap

Hi Suman,

Thank you for the patch.

On Thursday 13 February 2014 12:15:33 Suman Anna wrote:
quoted hunk
From: Florian Vaussard <redacted>

omap_iommu_attach() returns NULL or ERR_PTR in case of error, but
omap_iommu_attach_dev() only checks for IS_ERR. Thus a NULL return value (in
case driver_find_device fails) will cause the kernel to panic when
omap_iommu_attach_dev() dereferences the pointer.

In such case, omap_iommu_attach() should return ENODEV, not NULL.

Signed-off-by: Florian Vaussard <redacted>
Acked-by: Suman Anna <redacted>
---
 drivers/iommu/omap-iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index fff2ffd..6272c36 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -863,7 +863,7 @@ static int device_match_by_alias(struct device *dev,
void *data) **/
 static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd)
 {
-	int err = -ENOMEM;
+	int err = -ENODEV;
 	struct device *dev;
 	struct omap_iommu *obj;
@@ -871,7 +871,7 @@ static struct omap_iommu *omap_iommu_attach(const char
*name, u32 *iopgd) (void *)name,
 				device_match_by_alias);
 	if (!dev)
-		return NULL;
+		return ERR_PTR(err);
I would return ERR_PTR(-ENODEV) here, and remove the initialization at 
declaration of err above.
 	obj = to_iommu(dev);
-- 
Regards,

Laurent Pinchart
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help