On Thu, Oct 31, 2024 at 07:27:59AM +0100, Oleksij Rempel wrote: > On Wed, Oct 30, 2024 at 05:53:07PM +0100, Kory Maincent wrote: > > ... > > /** > > * struct pse_control - a PSE control > > @@ -440,18 +441,22 @@ int pse_controller_register(struct pse_controller_dev *pcdev) > > > > mutex_init(&pcdev->lock); > > INIT_LIST_HEAD(&pcdev->pse_control_head); > > + ret = ida_alloc_max(&pse_ida, INT_MAX, GFP_KERNEL); > > s/INT_MAX/U32_MAX * Return: The allocated ID, or %-ENOMEM if memory could not be allocated, * or %-ENOSPC if there are no free IDs. static inline int ida_alloc_max(struct ida *ida, unsigned int max, gfp_t gfp) We need to be careful here, at least theoretically. Assuming a 32 bit system, and you pass it U32_MAX, how does it return values in the range S32_MAX..U32_MAX when it also needs to be able to return negative numbers as errors? I think the correct value to pass is S32_MAX, because it will always fit in a u32, and there is space left for negative values for errors. But this is probably theoretical, no real system should have that many controllers. Andrew