diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2014-09-16 12:10:40 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2014-09-24 19:36:42 -0400 |
commit | 920ac5be91bc447c5ef82f457207a169aa79c5f6 (patch) | |
tree | b79044cc494de592d1ccb733360bc1145add7de8 /drivers/power | |
parent | 628ef02c56e515430dd8d8439126dd0ecb8ce8bb (diff) |
power: max8925: Fix NULL ptr dereference on memory allocation failure
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.kozlowski@samsung.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/max8925_power.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
452 | pdata = devm_kzalloc(&pdev->dev, | 452 | pdata = devm_kzalloc(&pdev->dev, |
453 | sizeof(struct max8925_power_pdata), | 453 | sizeof(struct max8925_power_pdata), |
454 | GFP_KERNEL); | 454 | GFP_KERNEL); |
455 | if (!pdata) | ||
456 | goto ret; | ||
455 | 457 | ||
456 | of_property_read_u32(np, "topoff-threshold", &topoff_threshold); | 458 | of_property_read_u32(np, "topoff-threshold", &topoff_threshold); |
457 | of_property_read_u32(np, "batt-detect", &batt_detect); | 459 | of_property_read_u32(np, "batt-detect", &batt_detect); |
458 | of_property_read_u32(np, "fast-charge", &fast_charge); | 460 | of_property_read_u32(np, "fast-charge", &fast_charge); |
459 | of_property_read_u32(np, "no-insert-detect", &no_insert_detect); | 461 | of_property_read_u32(np, "no-insert-detect", &no_insert_detect); |
460 | of_property_read_u32(np, "no-temp-support", &no_temp_support); | 462 | of_property_read_u32(np, "no-temp-support", &no_temp_support); |
461 | of_node_put(np); | ||
462 | 463 | ||
463 | pdata->batt_detect = batt_detect; | 464 | pdata->batt_detect = batt_detect; |
464 | pdata->fast_charge = fast_charge; | 465 | pdata->fast_charge = fast_charge; |
@@ -466,6 +467,8 @@ max8925_power_dt_init(struct platform_device *pdev) | |||
466 | pdata->no_insert_detect = no_insert_detect; | 467 | pdata->no_insert_detect = no_insert_detect; |
467 | pdata->no_temp_support = no_temp_support; | 468 | pdata->no_temp_support = no_temp_support; |
468 | 469 | ||
470 | ret: | ||
471 | of_node_put(np); | ||
469 | return pdata; | 472 | return pdata; |
470 | } | 473 | } |
471 | #else | 474 | #else |