clocksource/drivers/timer-mediatek: Fix "no-cfi indirect call" warning
Subsystems (2)
PATCH 1/1 clocksource/drivers/timer-mediatek: Fix "no-cfi indirect call" warning
After converting the driver to OF probing, kernel-test-robot reported the following new warning:
vmlinux.o: warning: objtool: mtk_timer_probe+0x23: no-cfi indirect call!
This occurs because of_device_get_match_data() returns NULL when CONFIG_OF is disabled, which results in LLVM dropping the kCFI setup since it knows that there is no valid target for this call. Adding a check for a NULL timer_init avoids the warning and it makes the probe more robust since of_device_get_match_data() could return NULL even when CONFIG_OF=y.
--- drivers/clocksource/timer-mediatek.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clocksource/timer-mediatek.c +3 -0
@@ -353,6 +353,9 @@ static int mtk_timer_probe(struct platform_device *pdev)int (*timer_init)(struct platform_device *pdev); timer_init =of_device_get_match_data (&pdev->dev); +if (!timer_init) +return -ENODEV ; +return timer_init (pdev); }
Signature · 1 line
2.43.0
Quoted 12 lines · Luca Leonardo Scorcia
After converting the driver to OF probing, kernel-test-robot reported the following new warning:
vmlinux.o: warning: objtool:
mtk_timer_probe+0x23: no-cfi indirect call!This occurs because
of_device_get_match_data()returns NULL whenCONFIG_OFis disabled, which results in LLVM dropping the kCFI setup since it knows that there is no valid target for this call. Adding a check for a NULLtimer_initavoids the warning and it makes the probe more robust sinceof_device_get_match_data()could return NULL even whenCONFIG_OF=y.
Quoted 5 lines
Fixes 7a097aba7255 ("clocksource/drivers/timer-mediatek: Convert to OF probing")Reported-by kernel test robot <[email protected]>Suggested-by Nathan Chancellor <[email protected]>Signed-off-by Luca Leonardo Scorcia <[email protected]>
Quoted 21 lines
--- drivers/clocksource/timer-mediatek.c | 3 +++ 1 file changed, 3 insertions(+)drivers/clocksource/timer-mediatek.c +3
-0@@ -353,6 +353,9 @@ static int mtk_timer_probe(struct platform_device *pdev)int (*timer_init)(struct platform_device *pdev); timer_init =of_device_get_match_data (&pdev->dev); +if (!timer_init) +return -ENODEV ; +return timer_init (pdev); }Signature · 1 line
2.43.0
Signature · 2 lines
Cheers, Nathan