Return value for "impossible" situations

Bernd Petrovitsch bernd at
Sun Jul 25 14:59:30 EDT 2021

Hi all!

On 25/07/2021 20:07, Ian Pilcher wrote:
> For kernel code, I can use pr_err, dump_stack, WARN_ON, etc. to report
> the issue in the log, but I often also need to return some sort of error
> code (negative errno value).

This value goes up to userspace (otherwise it makes no real sense to use

> Is there any sort of convention around what to return in the case of an
> error in the logic of the code itself, something that will make it as
> obvious as possible that the problem is a bug.

That depends on the situation/sys-call/....
You habe to choose the value (the list and short explanation is in `man
errno`) which leads the userspace application and it's user in the best
And no, you can't invent new values.

Bernd Petrovitsch                  Email : bernd at
     There is NO CLOUD, just other people's computers. - FSFE
                     LUGA :

More information about the Kernelnewbies mailing list