557d02b822b3a99bcdc16abe77da389f6b4b447c
[openwrt/staging/hauke.git] / target / linux / mediatek / patches-6.1 / 350-17-cpufreq-mediatek-fix-passing-zero-to-PTR_ERR.patch
1 From 230a74d459244411db91bfd678f17fcf7aedfcd0 Mon Sep 17 00:00:00 2001
2 From: Jia-Wei Chang <jia-wei.chang@mediatek.com>
3 Date: Fri, 24 Mar 2023 18:11:27 +0800
4 Subject: [PATCH 17/21] cpufreq: mediatek: fix passing zero to 'PTR_ERR'
5
6 In order to prevent passing zero to 'PTR_ERR' in
7 mtk_cpu_dvfs_info_init(), we fix the return value of of_get_cci() using
8 error pointer by explicitly casting error number.
9
10 Signed-off-by: Jia-Wei Chang <jia-wei.chang@mediatek.com>
11 Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU")
12 Reported-by: Dan Carpenter <error27@gmail.com>
13 Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
14 Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
15 ---
16 drivers/cpufreq/mediatek-cpufreq.c | 10 +++++-----
17 1 file changed, 5 insertions(+), 5 deletions(-)
18
19 --- a/drivers/cpufreq/mediatek-cpufreq.c
20 +++ b/drivers/cpufreq/mediatek-cpufreq.c
21 @@ -373,13 +373,13 @@ static struct device *of_get_cci(struct
22 struct platform_device *pdev;
23
24 np = of_parse_phandle(cpu_dev->of_node, "mediatek,cci", 0);
25 - if (IS_ERR_OR_NULL(np))
26 - return NULL;
27 + if (!np)
28 + return ERR_PTR(-ENODEV);
29
30 pdev = of_find_device_by_node(np);
31 of_node_put(np);
32 - if (IS_ERR_OR_NULL(pdev))
33 - return NULL;
34 + if (!pdev)
35 + return ERR_PTR(-ENODEV);
36
37 return &pdev->dev;
38 }
39 @@ -401,7 +401,7 @@ static int mtk_cpu_dvfs_info_init(struct
40 info->ccifreq_bound = false;
41 if (info->soc_data->ccifreq_supported) {
42 info->cci_dev = of_get_cci(info->cpu_dev);
43 - if (IS_ERR_OR_NULL(info->cci_dev)) {
44 + if (IS_ERR(info->cci_dev)) {
45 ret = PTR_ERR(info->cci_dev);
46 dev_err(cpu_dev, "cpu%d: failed to get cci device\n", cpu);
47 return -ENODEV;