drivers: Perform a runtime check if a driver is capable of an operation
Driver APIs might not implement all operations, making it possible for a user thread to get the kernel to execute a function at 0x00000000. Perform runtime checks in all the driver handlers, checking if they're capable of performing the requested operation. Fixes #6907. Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
parent
e7ded11a2e
commit
c200367b68
20 changed files with 224 additions and 119 deletions
|
@ -7,17 +7,32 @@
|
|||
#include <syscall_handler.h>
|
||||
#include <rtc.h>
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE(rtc_read, K_OBJ_DRIVER_RTC, struct device *);
|
||||
_SYSCALL_HANDLER(rtc_read, dev)
|
||||
{
|
||||
_SYSCALL_DRIVER_RTC(dev, read);
|
||||
return _impl_rtc_read((struct device *)dev);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE_VOID(rtc_enable, K_OBJ_DRIVER_RTC, struct device *);
|
||||
_SYSCALL_HANDLER(rtc_enable, dev)
|
||||
{
|
||||
_SYSCALL_DRIVER_RTC(dev, enable);
|
||||
return _impl_rtc_enable((struct device *)dev);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE_VOID(rtc_disable, K_OBJ_DRIVER_RTC, struct device *);
|
||||
_SYSCALL_HANDLER(rtc_disable, dev)
|
||||
{
|
||||
_SYSCALL_DRIVER_RTC(dev, disable);
|
||||
return _impl_rtc_disable((struct device *)dev);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER(rtc_set_alarm, dev, alarm_val)
|
||||
{
|
||||
_SYSCALL_OBJ(dev, K_OBJ_DRIVER_RTC);
|
||||
_SYSCALL_DRIVER_RTC(dev, set_alarm);
|
||||
return _impl_rtc_set_alarm((struct device *)dev, alarm_val);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE(rtc_get_pending_int, K_OBJ_DRIVER_RTC,
|
||||
struct device *);
|
||||
_SYSCALL_HANDLER(rtc_get_pending_int, dev)
|
||||
{
|
||||
_SYSCALL_DRIVER_RTC(dev, get_pending_int);
|
||||
return _impl_rtc_get_pending_int((struct device *)dev);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue