Re: [PATCH v4] ptp: ocp: Limit signal/freq counts in show/store functions

Vadim Fedorenko
2025-05-11T21:16:39Z

On 11/05/2025 16:42, Sagi Maimon wrote:
> The sysfs show/store operations could access uninitialized elements
> in the freq_in[] and signal_out[] arrays, leading to NULL pointer
> dereferences. This patch introduces u8 fields (nr_freq_in,
> nr_signal_out) to track the number of initialized elements, capping
> the maximum at 4 for each array. The show/store functions are updated
> to respect these limits, preventing out-of-bounds access and ensuring
> safe array handling.
>
> Signed-off-by: Sagi Maimon <maimon.sagi@gmail.com>

LGTM,
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>