rtc: synqmp: uninitialized variable error
Subsystems (2)
PATCH 1/1 rtc: synqmp: uninitialized variable error
fract_tick is uninitialized and can lead to uninitialized read which can result in any arbitrary value from previous computations. If the code flow doesnt execute the if (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) { block, fract_tick is left uninitialized. Initializing with zero fixes the issue.
--- drivers/rtc/rtc-zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-zynqmp.c +1 -1
@@ -203,7 +203,7 @@ static int xlnx_rtc_set_offset(struct device *dev, long offset)struct xlnx_rtc_dev *xrtcdev =dev_get_drvdata (dev);unsigned long long rtc_ppb =RTC_PPB ;unsigned int tick_mult =do_div (rtc_ppb, xrtcdev->freq); -unsigned char fract_tick; +unsigned char fract_tick =0 ;unsigned int calibval;short int max_tick;int fract_offset;
Signature · 1 line
2.34.1
Michal Simek
maintainerHi,
Quoted 26 lines · Sebin Sebastian
fract_tickis uninitialized and can lead to uninitialized read which can result in any arbitrary value from previous computations. If the code flow doesnt execute theif (fract_offset > (tick_mult / RTC_FR_MAX_TICKS)) {block,fract_tickis left uninitialized. Initializing with zero fixes the issue.Signed-off-by Sebin Sebastian <[email protected]>--- drivers/rtc/rtc-zynqmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/rtc/rtc-zynqmp.c +1
-2@@ -203,7 +203,7 @@ static int xlnx_rtc_set_offset(struct device *dev, long offset)struct xlnx_rtc_dev *xrtcdev =dev_get_drvdata (dev);unsigned long long rtc_ppb =RTC_PPB ;unsigned int tick_mult =do_div (rtc_ppb, xrtcdev->freq); -unsigned char fract_tick; +unsigned char fract_tick =0 ;unsigned int calibval;short int max_tick;int fract_offset; --
Quoted 2 lines
2.34.1
Alexandre already send the patch for it here.
https://lore.kernel.org/r/[email protected]
Thanks,
Michal