Re: [PATCH v4 1/3] usb: typec: ucsi: Limit read size on v1.2

From: Andy Shevchenko
Date: Fri Feb 09 2024 - 09:28:51 EST


On Thu, Feb 08, 2024 at 10:02:38PM -0800, Abhishek Pandit-Subedi wrote:
> Between UCSI 1.2 and UCSI 2.0, the size of the MESSAGE_IN region was
> increased from 16 to 256. In order to avoid overflowing reads for older
> systems, add a mechanism to use the read UCSI version to truncate read
> sizes on UCSI v1.2.

..

> + if (ucsi->version <= UCSI_VERSION_1_2)
> + buf_size = min_t(size_t, 16, buf_size);

Please, avoid using min_t(). Here the clamp() can be used.
Shouldn't magic number be defined?

--
With Best Regards,
Andy Shevchenko