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

Commit 8606f531 authored by Da Hoon Pyun's avatar Da Hoon Pyun
Browse files

msm: npu: Check for npu bandwidth node before assignment



This change is to ensure npu bandwidth nodes are valid before
assigning the variable for use.

Change-Id: I3ba1b9f9ba236ef4a0078bdb4ea065761a0217fe
Signed-off-by: default avatarDa Hoon Pyun <dpyun@codeaurora.org>
parent cfab2293
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -1896,6 +1896,8 @@ static int npu_pwrctrl_init(struct npu_device *npu_dev)
	struct platform_device *p2dev;
	struct npu_pwrctrl *pwr = &npu_dev->pwrctrl;

	pwr->devbw_num = 0;

	/* Power levels */
	node = of_find_node_by_name(pdev->dev.of_node, "qcom,npu-pwrlevels");

@@ -1909,15 +1911,17 @@ static int npu_pwrctrl_init(struct npu_device *npu_dev)
		return ret;

	/* Parse Bandwidth Monitor */
	pwr->devbw_num = of_property_count_strings(pdev->dev.of_node,
	ret = of_property_count_strings(pdev->dev.of_node,
			"qcom,npubw-dev-names");
	if (pwr->devbw_num <= 0) {
	if (ret <= 0) {
		NPU_INFO("npubw-dev-names are not defined\n");
		return 0;
	} else if (pwr->devbw_num > NPU_MAX_BW_DEVS) {
		NPU_ERR("number of devbw %d exceeds limit\n", pwr->devbw_num);
	} else if (ret > NPU_MAX_BW_DEVS) {
		NPU_ERR("number of devbw %d exceeds limit\n", ret);
		return -EINVAL;
	}
	pwr->devbw_num = ret;
	ret = 0;

	for (i = 0; i < pwr->devbw_num; i++) {
		node = of_parse_phandle(pdev->dev.of_node,