From: Munehisa Kamata <kamatam@amazon.com>
To: <thierry.reding@gmail.com>
Cc: <u.kleine-koenig@pengutronix.de>, <tobetter@gmail.com>,
<linux-pwm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Munehisa Kamata <kamatam@amazon.com>, <stable@vger.kernel.org>
Subject: [PATCH] pwm: core: Zero-initialize the temp state
Date: Sat, 25 Feb 2023 17:37:21 -0800 [thread overview]
Message-ID: <20230226013722.1802842-1-kamatam@amazon.com> (raw)
Zero-initialize the on-stack structure to avoid unexpected behaviors. Some
drivers may not set or initialize all the values in pwm_state through their
.get_state() callback and therefore some random values may remain there and
be set into pwm->state eventually.
This actually caused regression on ODROID-N2+ as reported in [1]; kernel
fails to boot due to random panic or hang-up.
[1] https://forum.odroid.com/viewtopic.php?f=177&t=46360
Fixes: c73a3107624d ("pwm: Handle .get_state() failures")
Cc: stable@vger.kernel.org # 6.2
Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
---
drivers/pwm/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index e01147f66e15..6eac8022a2c2 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -117,6 +117,7 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label)
if (pwm->chip->ops->get_state) {
struct pwm_state state;
+ memset(&state, 0, sizeof(struct pwm_state));
err = pwm->chip->ops->get_state(pwm->chip, pwm, &state);
trace_pwm_get(pwm, &state, err);
--
2.25.1
next reply other threads:[~2023-02-26 1:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-26 1:37 Munehisa Kamata [this message]
2023-02-26 9:17 ` [PATCH] pwm: core: Zero-initialize the temp state Uwe Kleine-König
2023-02-27 2:48 ` Munehisa Kamata
2023-02-27 9:16 ` Uwe Kleine-König
2023-02-28 8:53 ` Munehisa Kamata
2023-02-28 9:39 ` Uwe Kleine-König
2023-02-28 10:15 ` [PATCH] pwm: Zero-initialize the pwm_state passed to driver's .get_state() Uwe Kleine-König
2023-02-28 19:43 ` Munehisa Kamata
2023-02-28 21:48 ` Uwe Kleine-König
2023-03-10 19:15 ` Uwe Kleine-König
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=20230226013722.1802842-1-kamatam@amazon.com \
--to=kamatam@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=tobetter@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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