Re: [PATCH] kernel/itimer.c: for return value, using -EINVAL insteadof -EFAULT

From: Thomas Gleixner
Date: Thu Jun 20 2013 - 02:59:37 EST


On Thu, 20 Jun 2013, Chen Gang wrote:

> For the system call getitimer(), if the parameter 'value' is NULL, need
> return -EINVAL, not -EFAULT.

Care to explain why? Because you are feeling so?

I recommend reading the man page of getitimer:

ERRORS
EFAULT new_value, old_value, or curr_value is not valid a pointer.

And NULL is definitely NOT a valid pointer.

The Posix spec does not specify an explicit error value for this
syscall, but the general policy is:

[EFAULT]
Bad address. The system detected an invalid address in attempting
to use an argument of a call. The reliable detection of this error
cannot be guaranteed, and when not detected may result in the
generation of a signal, indicating an address violation, which is
sent to the process.

And we made use of this, which is correct and makes sense.

Returning EINVAL makes no sense at all, because EINVAL _IS_ a
specified error code for this syscall:

[EINVAL]
The which argument is not recognized.

Thanks,

tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/