Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57132f55 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar Committed by David Collins
Browse files

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: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 370a4fae
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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");