summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhijeet Dharmapurikar <adharmap@codeaurora.org>2016-09-13 11:10:48 -0700
committerAbhijeet Dharmapurikar <adharmap@codeaurora.org>2016-10-31 15:40:26 -0700
commit5558abe40041f6db4c310277134c2bf3f86fccfc (patch)
treec17ed464850a0d3b9cd87aa1947eff792befdde0
parentbbd8499b43c68d14ee8d4be46680f59516f81a70 (diff)
spmi-pmic-arb: fix a possible null pointer dereference
If "core" memory resource is not specified, the driver could end up dereferencing a null pointer. Fix this by returning -EINVAL when core resource is missing. Change-Id: Id08f7b2e109b6b2963b19dfe07f07cbfb424202b Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
-rw-r--r--drivers/spmi/spmi-pmic-arb.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c
index b02e48185355..c0b936d802ef 100644
--- a/drivers/spmi/spmi-pmic-arb.c
+++ b/drivers/spmi/spmi-pmic-arb.c
@@ -1005,6 +1005,12 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev)
pa->spmic = ctrl;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
+ if (!res) {
+ dev_err(&pdev->dev, "core resource not specified\n");
+ err = -EINVAL;
+ goto err_put_ctrl;
+ }
+
pa->core_size = resource_size(res);
if (pa->core_size <= 0x800) {
dev_err(&pdev->dev, "core_size is smaller than 0x800. Failing Probe\n");