From: Alexandr Sapozhnkiov <alsp705@gmail.com>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alexandr Sapozhnikov <alsp705@gmail.com>,
linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH] rtc: fix error checking in wdt_disable()
Date: Thu, 2 Oct 2025 12:24:52 +0300 [thread overview]
Message-ID: <20251002092456.11-1-alsp705@gmail.com> (raw)
From: Alexandr Sapozhnikov <alsp705@gmail.com>
The i2c_transfer() function may return an error.
Ignoring errors returned by functions is bad practice.
Especially when these functions perform core functionality.
What's the point of continuing to call the same function
after an error is returned?
If the second function call succeeds, data corruption will occur.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
drivers/rtc/rtc-m41t80.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 0013bff0447d..b24d09c57816 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -677,11 +677,11 @@ static void wdt_disable(void)
};
i2c_data[0] = 0x09;
- i2c_transfer(save_client->adapter, msgs0, 2);
-
- i2c_data[0] = 0x09;
- i2c_data[1] = 0x00;
- i2c_transfer(save_client->adapter, msgs1, 1);
+ if (!i2c_transfer(save_client->adapter, msgs0, 2)) {
+ i2c_data[0] = 0x09;
+ i2c_data[1] = 0x00;
+ i2c_transfer(save_client->adapter, msgs1, 1);
+ }
}
/**
--
2.43.0
next reply other threads:[~2025-10-02 9:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 9:24 Alexandr Sapozhnkiov [this message]
2025-10-03 13:50 ` [PATCH] rtc: fix error checking in wdt_disable() Markus Elfring
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=20251002092456.11-1-alsp705@gmail.com \
--to=alsp705@gmail.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
/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