From: Hauke Mehrtens Date: Fri, 7 Feb 2014 23:52:42 +0000 (+0100) Subject: backports: add compat_put_timespec() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0706870c48a0ba538e87381feca2bb0e204b6c71;p=openwrt%2Fstaging%2Fblogic.git backports: add compat_put_timespec() This is used by v4l2-compat-ioctl32.c Signed-off-by: Hauke Mehrtens --- diff --git a/backport/backport-include/linux/compat.h b/backport/backport-include/linux/compat.h index 22db9b0f7be3..07accd2ec667 100644 --- a/backport/backport-include/linux/compat.h +++ b/backport/backport-include/linux/compat.h @@ -13,4 +13,9 @@ #endif #endif +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +#define compat_put_timespec LINUX_BACKPORT(compat_put_timespec) +extern int compat_put_timespec(const struct timespec *, void __user *); +#endif + #endif /* __BACKPORT_COMPAT_H */ diff --git a/backport/compat/compat-3.4.c b/backport/compat/compat-3.4.c index fafe0dfd87ae..bc090b7830d6 100644 --- a/backport/compat/compat-3.4.c +++ b/backport/compat/compat-3.4.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include @@ -179,3 +181,21 @@ int simple_open(struct inode *inode, struct file *file) return 0; } EXPORT_SYMBOL_GPL(simple_open); + +#ifdef CONFIG_COMPAT +static int __compat_put_timespec(const struct timespec *ts, struct compat_timespec __user *cts) +{ + return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) || + __put_user(ts->tv_sec, &cts->tv_sec) || + __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; +} + +int compat_put_timespec(const struct timespec *ts, void __user *uts) +{ + if (COMPAT_USE_64BIT_TIME) + return copy_to_user(uts, ts, sizeof *ts) ? -EFAULT : 0; + else + return __compat_put_timespec(ts, uts); +} +EXPORT_SYMBOL_GPL(compat_put_timespec); +#endif