On Wed, Jun 14, 2023 at 01:05:45PM +0000, Liu, Yi L wrote: > > -EAGAIN basically means the kernel internally malfunctioned - eg it > > allocated too little space for the actual size of devices. That is no > > longer possible in this version so it should never return -EAGAIN. > > I still have one doubt. Per my understanding, this is to handle newly > plugged devices during the info reporting path. I don’t think holding > dev_set lock can prevent it. but maybe -ENOSPC is enough. @Alex, > what about your opinion? If the device was plug instantly before we computed the size we returned ENOSPC If it was plugged instantly after we computed the size we returned EAGAIN Here we just resolve this race consistently to always return ENOSPC, which always means we ran out of space in the user provided buffer. > > - kfree(devices); > > - return ret; > > + if (fill.count != fill.devices - arg->devices) > > Should be "if (fill.count != (fill.devices - arg->devices) / sizeof(arg->devices[0]))" 😊 devices is already a typed pointer so the compiler computes the /sizeof() itself Your version above is needed if it was void * Jason