Skip to content

Commit d51c632

Browse files
jiaweichang-mtkvireshk
authored andcommitted
cpufreq: mediatek: fix passing zero to 'PTR_ERR'
In order to prevent passing zero to 'PTR_ERR' in mtk_cpu_dvfs_info_init(), we fix the return value of of_get_cci() using error pointer by explicitly casting error number. Signed-off-by: Jia-Wei Chang <jia-wei.chang@mediatek.com> Fixes: 0daa473 ("cpufreq: mediatek: Link CCI device to CPU") Reported-by: Dan Carpenter <error27@gmail.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent b8f3a39 commit d51c632

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ static struct device *of_get_cci(struct device *cpu_dev)
373373
struct platform_device *pdev;
374374

375375
np = of_parse_phandle(cpu_dev->of_node, "mediatek,cci", 0);
376-
if (IS_ERR_OR_NULL(np))
377-
return NULL;
376+
if (!np)
377+
return ERR_PTR(-ENODEV);
378378

379379
pdev = of_find_device_by_node(np);
380380
of_node_put(np);
381-
if (IS_ERR_OR_NULL(pdev))
382-
return NULL;
381+
if (!pdev)
382+
return ERR_PTR(-ENODEV);
383383

384384
return &pdev->dev;
385385
}
@@ -401,7 +401,7 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
401401
info->ccifreq_bound = false;
402402
if (info->soc_data->ccifreq_supported) {
403403
info->cci_dev = of_get_cci(info->cpu_dev);
404-
if (IS_ERR_OR_NULL(info->cci_dev)) {
404+
if (IS_ERR(info->cci_dev)) {
405405
ret = PTR_ERR(info->cci_dev);
406406
dev_err(cpu_dev, "cpu%d: failed to get cci device\n", cpu);
407407
return -ENODEV;

0 commit comments

Comments
 (0)