[PATCH V4 2/4] spmi: pmic-arb: fix a possible null pointer dereference

From: Kiran Gunda
Date: Tue Jul 18 2017 - 06:21:42 EST


If "core" memory resource is not specified, then the driver could
end up dereferencing a null pointer. Fix this issue.

Signed-off-by: Kiran Gunda <kgunda@xxxxxxxxxxxxxx>
Reviewed-by: Stephen Boyd <sboyd@xxxxxxxxxxxxxx>
---
drivers/spmi/spmi-pmic-arb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index 8982591..156f776 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -956,14 +956,14 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
pmic_arb->spmic = ctrl;

res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
- pmic_arb->core_size = resource_size(res);
-
core = devm_ioremap_resource(&ctrl->dev, res);
if (IS_ERR(core)) {
err = PTR_ERR(core);
goto err_put_ctrl;
}

+ pmic_arb->core_size = resource_size(res);
+
pmic_arb->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID,
sizeof(*pmic_arb->ppid_to_apid),
GFP_KERNEL);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project