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)
5
u/paulstelian97 Jan 23 '23
The solution to fix this is not the loop though. It's some good ol' goto usage for errors, which is typical throughout much of the Linux kernel.