Re: [PATCH v2][next] hwmon: (aspeed-pwm-tacho) Fix -Wstringop-overflow warning in aspeed_create_fan_tach_channel()

Guenter Roeck
2023-11-15T13:12:20Z

On Tue, Nov 14, 2023 at 01:53:08PM -0600, Gustavo A. R. Silva wrote:
> Based on the documentation below, the maximum number of Fan tach
> channels is 16:
>
> Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt:45:
> 45 - aspeed,fan-tach-ch : should specify the Fan tach input channel.
> 46 integer value in the range 0 through 15, with 0 indicating
> 47 Fan tach channel 0 and 15 indicating Fan tach channel 15.
> 48 At least one Fan tach input channel is required.
>
> However, the compiler doesn't know that, and legitimaly warns about a potential
> overwrite in array `u8 fan_tach_ch_source[16]` in `struct aspeed_pwm_tacho_data`,
> in case `index` takes a value outside the boundaries of the array:
>

Still messes the point. This isn't about "the compiler doesn't know that",
it is a real bug which may result in out-of-bounds accesses.

Oh, never mind, I'll just apply it.

Guenter