From: Sebin Sebastian <mailmesebin00@gmail.com>
Cc: mailmesebin00@gmail.com, Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Michal Simek <michal.simek@xilinx.com>,
linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH -next] rtc: synqmp: uninitialized variable error
Date: Wed, 3 Aug 2022 07:01:17 +0530 [thread overview]
Message-ID: <20220803013117.318611-1-mailmesebin00@gmail.com> (raw)
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
next reply other threads:[~2022-08-03 1:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 1:31 Sebin Sebastian [this message]
2022-08-03 5:46 ` [PATCH -next] rtc: synqmp: uninitialized variable error Michal Simek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220803013117.318611-1-mailmesebin00@gmail.com \
--to=mailmesebin00@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=michal.simek@xilinx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).