Hi Andrew,

On 8/8/25 11:16, Andrew Goodbody wrote:
I have the following Smatch report.

drivers/pwm/pwm-cadence-ttc.c:73 cadence_ttc_pwm_set_invert() error: buffer overflow 'priv->invert' 2 <= 2 drivers/pwm/pwm-cadence-ttc.c:138 cadence_ttc_pwm_set_config() error: buffer overflow 'priv->invert' 2 <= 2

Indeed yes, the code allows a maximum index of 2 into an array with 2 elements, so that is out of bounds. My question is which is wrong? Should the array have 3 elements or should the index be limited to 1, or is the value being checked 1 based?

There are maximum 3 PWMs.

I think the best way to fix would be to create macro with number 3 and use it in array and in boundary check too.

Thanks,
Michal

Reply via email to