[PATCH] pwm: max7360: populate missing .sizeof_wfhw in max7360_pwm_ops

Richard Genoud posted 1 patch 3 weeks, 4 days ago
drivers/pwm/pwm-max7360.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] pwm: max7360: populate missing .sizeof_wfhw in max7360_pwm_ops
Posted by Richard Genoud 3 weeks, 4 days ago
The sizeof_wfhw field wasn't populated in max7360_pwm_ops so it was set
to 0 by default.
While this is ok for now because:
sizeof(struct max7360_pwm_waveform) < PWM_WFHWSIZE
in the future, if struct max7360_pwm_waveform grows, it could lead to
stack corruption.

Fixes: d93a75d94b79 ("pwm: max7360: Add MAX7360 PWM support")
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
---
 drivers/pwm/pwm-max7360.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pwm/pwm-max7360.c b/drivers/pwm/pwm-max7360.c
index 16261958ce7f..732969303dd7 100644
--- a/drivers/pwm/pwm-max7360.c
+++ b/drivers/pwm/pwm-max7360.c
@@ -153,6 +153,7 @@ static int max7360_pwm_read_waveform(struct pwm_chip *chip,
 }
 
 static const struct pwm_ops max7360_pwm_ops = {
+	.sizeof_wfhw = sizeof(struct max7360_pwm_waveform),
 	.request = max7360_pwm_request,
 	.round_waveform_tohw = max7360_pwm_round_waveform_tohw,
 	.round_waveform_fromhw = max7360_pwm_round_waveform_fromhw,

base-commit: 0f61b1860cc3f52aef9036d7235ed1f017632193
-- 
2.47.3
Re: [PATCH] pwm: max7360: populate missing .sizeof_wfhw in max7360_pwm_ops
Posted by Uwe Kleine-König 3 weeks, 3 days ago
Hello Richard,

On Tue, Jan 13, 2026 at 05:39:07PM +0100, Richard Genoud wrote:
> The sizeof_wfhw field wasn't populated in max7360_pwm_ops so it was set
> to 0 by default.
> While this is ok for now because:
> sizeof(struct max7360_pwm_waveform) < PWM_WFHWSIZE
> in the future, if struct max7360_pwm_waveform grows, it could lead to
> stack corruption.
> 
> Fixes: d93a75d94b79 ("pwm: max7360: Add MAX7360 PWM support")
> Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
> ---
>  drivers/pwm/pwm-max7360.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/pwm/pwm-max7360.c b/drivers/pwm/pwm-max7360.c
> index 16261958ce7f..732969303dd7 100644
> --- a/drivers/pwm/pwm-max7360.c
> +++ b/drivers/pwm/pwm-max7360.c
> @@ -153,6 +153,7 @@ static int max7360_pwm_read_waveform(struct pwm_chip *chip,
>  }
>  
>  static const struct pwm_ops max7360_pwm_ops = {
> +	.sizeof_wfhw = sizeof(struct max7360_pwm_waveform),
>  	.request = max7360_pwm_request,
>  	.round_waveform_tohw = max7360_pwm_round_waveform_tohw,
>  	.round_waveform_fromhw = max7360_pwm_round_waveform_fromhw,

good catch. For the reason stated in the commit log I'd not consider
that urgent (so I won't bother Linus with it before 6.19).

I applied it as is to

	https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next

. But I'm still taking review tags.

Best regards
Uwe