linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: core: Zero-initialize the temp state
@ 2023-02-26  1:37 Munehisa Kamata
  2023-02-26  9:17 ` 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
  0 siblings, 2 replies; 10+ messages in thread
From: Munehisa Kamata @ 2023-02-26  1:37 UTC (permalink / raw)
  To: thierry.reding
  Cc: u.kleine-koenig, tobetter, linux-pwm, linux-kernel,
	Munehisa Kamata, stable

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-10 19:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-26  1:37 [PATCH] pwm: core: Zero-initialize the temp state Munehisa Kamata
2023-02-26  9:17 ` 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

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).