Skip to contentSkip to conversation

pps: Return PTR_ERR on error in device_create

PATCH In review Emil Goode 2 participants 2 messages Jun 1, 2012 – Jul 14, 2012

Subsystems (2)
lore
Share & tools
lore

Emil Goode

author
#0 lore raw

PATCH 1/1 pps: Return PTR_ERR on error in device_create

We should return PTR_ERR if the call to the
device_create function fails.
Without this patch we instead return the value
from a successful call to cdev_add if the call
to device_create fails.

---
 drivers/pps/pps.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pps/pps.c +3 -1
index 98fbe62..e771487 100644
@@ -327,8 +327,10 @@ int pps_register_cdev(struct pps_device *pps)
 	}
 	pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
 							"pps%d", pps->id);
-	if (IS_ERR(pps->dev))
+	if (IS_ERR(pps->dev)) {
+		err = PTR_ERR(pps->dev);
 		goto del_cdev;
+	}
 
 	pps->dev->release = pps_device_destruct;
 
Signature · 1 line
1.7.10
Acked-by on v1 1/1
#1 lore raw

CCing Andrew Morton, and Alexander Gordeev based on git log drivers/pps/pps.c Pardon me if i made wrong

Quoted 28 lines · Emil Goode

We should return PTR_ERR if the call to the
device_create function fails.
Without this patch we instead return the value
from a successful call to cdev_add if the call
to device_create fails.

---
 drivers/pps/pps.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pps/pps.c +3 -2
index 98fbe62..e771487 100644
@@ -327,8 +327,10 @@ int pps_register_cdev(struct pps_device *pps)
        }
        pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
                                                        "pps%d", pps->id);
-       if (IS_ERR(pps->dev))
+       if (IS_ERR(pps->dev)) {
+               err = PTR_ERR(pps->dev);
                goto del_cdev;
+       }
 
        pps->dev->release = pps_device_destruct;
 
--
Quoted 2 lines

1.7.10

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/