Skip to contentSkip to conversation

charger-manager: Fix checking of wrong return type

PATCH In review [email protected] 2 participants 2 messages Mar 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 charger-manager: Fix checking of wrong return type

From: Chanwoo Choi <[email protected]>

This patch fix minor issue about checking wrong return type.

The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen in this function. But, charger_manager_probe() has only checked whether desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing DT, charger_manager_probe() can't detect error of desc instance.

---
 drivers/power/charger-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/charger-manager.c +1 -1
index 9e4dab4..a10fb57 100644
@@ -1677,7 +1677,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (!desc) {
+	if (IS_ERR(desc)) {
 		dev_err(&pdev->dev, "No platform data (desc) found\n");
 		return -ENODEV;
 	}
Signature · 1 line
1.8.0
#1 lore raw

Dear all,

Ignore this patch due to wrong e-mail address.
I'll resend patch.

Thanks,
Chanwoo Choi

Quoted 30 lines · On 03/17/2014 08:31 PM, [email protected] wrote:

From: Chanwoo Choi <[email protected]>

This patch fix minor issue about checking wrong return type.

The of_cm_parse_desc() return ERR_PTR(errnor number) when some error happen in this function. But, charger_manager_probe() has only checked whether desc is NULL or not. If of_cm_parse_desc() returns ERR_PTR(-ENOMEM), desc isn't NULL but desc is (void *)(-ENOMEM). Althouhg some error happen for parsing DT, charger_manager_probe() can't detect error of desc instance.

---
 drivers/power/charger-manager.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/charger-manager.c +1 -1
index 9e4dab4..a10fb57 100644
@@ -1677,7 +1677,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (!desc) {
+	if (IS_ERR(desc)) {
 		dev_err(&pdev->dev, "No platform data (desc) found\n");
 		return -ENODEV;
 	}