Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Integer overflow in devfreq load calculation on 32-bit architectures --
--- Patch [2]: [PATCH v4 02/13] drm/panfrost: Prevent division by 0 --- commit 1a597fba6ac1a7783fb883935107fe50d2c19cfa Author: Adrián Larumbe <[email protected]> drm/panfrost: Prevent division by 0 This commit modifies the devfreq status calculation to prevent a division by zero when the total device time is less than 100 ns. It updates the debug logging divisor and rearranges the operands. Closes: https://gitlab.freedesktop.org/panfrost/linux/-/work_items/88 > diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > index b51c307788110..0fe81d259274e 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c > +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c > @@ -78,7 +78,7 @@ static int panfrost_devfreq_get_dev_status(struct device > *dev, > > dev_dbg(pfdev->base.dev, "busy %lu total %lu %lu %% freq %lu MHz\n", > status->busy_time, status->total_time, > - status->busy_time / (status->total_time / 100), > + status->busy_time * 100 / MAX(status->total_time, 1), [Severity: Medium] Will this cause an integer overflow on 32-bit architectures? In panfrost_devfreq_get_dev_status(), status->busy_time is an unsigned long, which is 32 bits on platforms like ARM32. Since the Panfrost devfreq polling interval is 50ms, a fully busy GPU will have a status->busy_time around 50,000,000 ns. Multiplying 50,000,000 by 100 yields 5,000,000,000, which overflows the 32-bit ULONG_MAX (4,294,967,295) and wraps around to 705,032,704. When this is divided by 50,000,000, it results in 14% instead of the expected 100%. Could this be calculated using a 64-bit type or a div-related macro to prevent the debug log from reporting incorrect load percentages on heavily loaded 32-bit systems? > status->current_frequency / 1000 / 1000); > > return 0; -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
