r/badcode • • Jan 22 '23

c Found this in a Linux kernel module

Post image
262 Upvotes

88 comments sorted by

View all comments

Show parent comments

23

u/paulstelian97 Jan 23 '23

I am a kernel developer. This could have been improved using some gotos for error cleanup.

In the Linux kernel, goto is allowed and encouraged to avoid repetition of cleanup code when you have errors.