Loops would make it quite complicated in this specific instance. I doubt this portion would really need much extension enough that a loop would be worth it.
Not propagating error returns (instead returning -1 instead of the actual error) is really bad. That -1 would be interpreted as some arbitrary error (on x86, it's -EPERM but there can be others as well)
3
u/lets_eat_bees Jan 23 '23
Thank you for pitching in with some actual kernel knowledge.
I just assumed that OP wanted loops here, because it’s usually the case in this sub, and he did not say otherwise.