[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-09-16 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski 
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(>dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, "topoff-threshold", _threshold);
of_property_read_u32(np, "batt-detect", _detect);
of_property_read_u32(np, "fast-charge", _charge);
of_property_read_u32(np, "no-insert-detect", _insert_detect);
of_property_read_u32(np, "no-temp-support", _temp_support);
-   of_node_put(np);
 
pdata->batt_detect = batt_detect;
pdata->fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata->no_insert_detect = no_insert_detect;
pdata->no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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


[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-09-16 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(pdev-dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, topoff-threshold, topoff_threshold);
of_property_read_u32(np, batt-detect, batt_detect);
of_property_read_u32(np, fast-charge, fast_charge);
of_property_read_u32(np, no-insert-detect, no_insert_detect);
of_property_read_u32(np, no-temp-support, no_temp_support);
-   of_node_put(np);
 
pdata-batt_detect = batt_detect;
pdata-fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata-no_insert_detect = no_insert_detect;
pdata-no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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


[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-07-02 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski 
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(>dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, "topoff-threshold", _threshold);
of_property_read_u32(np, "batt-detect", _detect);
of_property_read_u32(np, "fast-charge", _charge);
of_property_read_u32(np, "no-insert-detect", _insert_detect);
of_property_read_u32(np, "no-temp-support", _temp_support);
-   of_node_put(np);
 
pdata->batt_detect = batt_detect;
pdata->fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata->no_insert_detect = no_insert_detect;
pdata->no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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


[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-07-02 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(pdev-dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, topoff-threshold, topoff_threshold);
of_property_read_u32(np, batt-detect, batt_detect);
of_property_read_u32(np, fast-charge, fast_charge);
of_property_read_u32(np, no-insert-detect, no_insert_detect);
of_property_read_u32(np, no-temp-support, no_temp_support);
-   of_node_put(np);
 
pdata-batt_detect = batt_detect;
pdata-fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata-no_insert_detect = no_insert_detect;
pdata-no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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


[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-04-23 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski 
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(>dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, "topoff-threshold", _threshold);
of_property_read_u32(np, "batt-detect", _detect);
of_property_read_u32(np, "fast-charge", _charge);
of_property_read_u32(np, "no-insert-detect", _insert_detect);
of_property_read_u32(np, "no-temp-support", _temp_support);
-   of_node_put(np);
 
pdata->batt_detect = batt_detect;
pdata->fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata->no_insert_detect = no_insert_detect;
pdata->no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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


[PATCH RESEND 1/2] power: max8925: Fix NULL ptr dereference on memory allocation failure

2014-04-23 Thread Krzysztof Kozlowski
Check the return value of devm_kzalloc() to fix possible NULL pointer
dereference and properly exit the probe() on memory allocation failure.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
---
 drivers/power/max8925_power.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f284bbc..0cf237808d47 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -452,13 +452,14 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata = devm_kzalloc(pdev-dev,
sizeof(struct max8925_power_pdata),
GFP_KERNEL);
+   if (!pdata)
+   goto ret;
 
of_property_read_u32(np, topoff-threshold, topoff_threshold);
of_property_read_u32(np, batt-detect, batt_detect);
of_property_read_u32(np, fast-charge, fast_charge);
of_property_read_u32(np, no-insert-detect, no_insert_detect);
of_property_read_u32(np, no-temp-support, no_temp_support);
-   of_node_put(np);
 
pdata-batt_detect = batt_detect;
pdata-fast_charge = fast_charge;
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev)
pdata-no_insert_detect = no_insert_detect;
pdata-no_temp_support = no_temp_support;
 
+ret:
+   of_node_put(np);
return pdata;
 }
 #else
-- 
1.9.1

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