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'
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.
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>
16 drivers/cpufreq/mediatek-cpufreq.c | 10 +++++-----
17 1 file changed, 5 insertions(+), 5 deletions(-)
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;
24 np = of_parse_phandle(cpu_dev->of_node, "mediatek,cci", 0);
25 - if (IS_ERR_OR_NULL(np))
28 + return ERR_PTR(-ENODEV);
30 pdev = of_find_device_by_node(np);
32 - if (IS_ERR_OR_NULL(pdev))
35 + return ERR_PTR(-ENODEV);
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);