* [PATCH -next] rtc: synqmp: uninitialized variable error
@ 2022-08-03 1:31 ` Sebin Sebastian
0 siblings, 0 replies; 4+ messages in thread
From: Sebin Sebastian @ 2022-08-03 1:31 UTC (permalink / raw)
Cc: mailmesebin00, Alessandro Zummo, Alexandre Belloni, Michal Simek,
linux-rtc, linux-arm-kernel, linux-kernel
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.
Signed-off-by: Sebin Sebastian <mailmesebin00@gmail.com>
---
drivers/rtc/rtc-zynqmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 1dd389b891fe..c9b85c838ebe 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH -next] rtc: synqmp: uninitialized variable error
@ 2022-08-03 1:31 ` Sebin Sebastian
0 siblings, 0 replies; 4+ messages in thread
From: Sebin Sebastian @ 2022-08-03 1:31 UTC (permalink / raw)
Cc: mailmesebin00, Alessandro Zummo, Alexandre Belloni, Michal Simek,
linux-rtc, linux-arm-kernel, linux-kernel
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.
Signed-off-by: Sebin Sebastian <mailmesebin00@gmail.com>
---
drivers/rtc/rtc-zynqmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
index 1dd389b891fe..c9b85c838ebe 100644
--- a/drivers/rtc/rtc-zynqmp.c
+++ b/drivers/rtc/rtc-zynqmp.c
@@ -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;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] rtc: synqmp: uninitialized variable error
2022-08-03 1:31 ` Sebin Sebastian
@ 2022-08-03 5:46 ` Michal Simek
-1 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2022-08-03 5:46 UTC (permalink / raw)
To: Sebin Sebastian
Cc: Alessandro Zummo, Alexandre Belloni, Michal Simek, linux-rtc,
linux-arm-kernel, linux-kernel
Hi,
On 8/3/22 03:31, Sebin Sebastian wrote:
>
> 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.
>
> Signed-off-by: Sebin Sebastian <mailmesebin00@gmail.com>
> ---
> drivers/rtc/rtc-zynqmp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 1dd389b891fe..c9b85c838ebe 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -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;
> --
> 2.34.1
>
Alexandre already send the patch for it here.
https://lore.kernel.org/r/20220727100018.3301470-1-alexandre.belloni@bootlin.com
Thanks,
Michal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] rtc: synqmp: uninitialized variable error
@ 2022-08-03 5:46 ` Michal Simek
0 siblings, 0 replies; 4+ messages in thread
From: Michal Simek @ 2022-08-03 5:46 UTC (permalink / raw)
To: Sebin Sebastian
Cc: Alessandro Zummo, Alexandre Belloni, Michal Simek, linux-rtc,
linux-arm-kernel, linux-kernel
Hi,
On 8/3/22 03:31, Sebin Sebastian wrote:
>
> 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.
>
> Signed-off-by: Sebin Sebastian <mailmesebin00@gmail.com>
> ---
> drivers/rtc/rtc-zynqmp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-zynqmp.c b/drivers/rtc/rtc-zynqmp.c
> index 1dd389b891fe..c9b85c838ebe 100644
> --- a/drivers/rtc/rtc-zynqmp.c
> +++ b/drivers/rtc/rtc-zynqmp.c
> @@ -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;
> --
> 2.34.1
>
Alexandre already send the patch for it here.
https://lore.kernel.org/r/20220727100018.3301470-1-alexandre.belloni@bootlin.com
Thanks,
Michal
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-03 5:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-03 1:31 [PATCH -next] rtc: synqmp: uninitialized variable error Sebin Sebastian
2022-08-03 1:31 ` Sebin Sebastian
2022-08-03 5:46 ` Michal Simek
2022-08-03 5:46 ` Michal Simek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.