Subject: Re: [PATCH net] stmmac: fix potential division by 0

From: Andrew Lunn <[email-masked]>
Date: Thu, 1 Dec 2022 02:39:03 +0100

On Thu, Dec 01, 2022 at 01:37:08AM +0100, Piergiorgio Beruto wrote:
> Depending on the HW platform and configuration, the
> stmmac_config_sub_second_increment() function may return 0 in the
> sec_inc variable. Therefore, the subsequent div_u64 operation can Oops
> the kernel because of the divisor being 0.

I'm wondering why it would return 0? Is the configuration actually
invalid? Is ptp_clock is too small, such that the value of data is
bigger than 255, but when masked with 0xff it gives zero?

I'm wondering if the correct thing to do is return -EINVAL in
stmmac_init_tstamp_counter().

So i would like an explanation of why it is zero.

Thanks
	Andrew