summaryrefslogtreecommitdiff
path: root/drivers/regulator/axp20x-regulator.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <garsilva@embeddedor.com>2017-07-07 00:49:18 +0300
committerMark Brown <broonie@kernel.org>2017-07-07 15:48:33 +0300
commitda2629684822091bf15c6c14d8e33b75dfce8637 (patch)
tree0304b11bc79c62dde3ad513be278ce7aaabd27ca /drivers/regulator/axp20x-regulator.c
parent8d67f64f7739464c352d4b167ed1748f3b2c1f44 (diff)
downloadlinux-da2629684822091bf15c6c14d8e33b75dfce8637.tar.xz
regulator: axp20x: add NULL check on devm_kzalloc() return value
Check return value from call to devm_kzalloc() in order to prevent a NULL pointer dereference. This issue was detected using Coccinelle and the following semantic patch: @@ expression x; identifier fld; @@ * x = devm_kzalloc(...); ... when != x == NULL x->fld Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator/axp20x-regulator.c')
-rw-r--r--drivers/regulator/axp20x-regulator.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index e2608fe770b9..f18b36dd57dd 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -691,6 +691,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
(regulators == axp809_regulators && i == AXP809_DC1SW)) {
new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
GFP_KERNEL);
+ if (!new_desc)
+ return -ENOMEM;
+
*new_desc = regulators[i];
new_desc->supply_name = dcdc1_name;
desc = new_desc;
@@ -700,6 +703,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
(regulators == axp809_regulators && i == AXP809_DC5LDO)) {
new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
GFP_KERNEL);
+ if (!new_desc)
+ return -ENOMEM;
+
*new_desc = regulators[i];
new_desc->supply_name = dcdc5_name;
desc = new_desc;