diff options
| -rw-r--r-- | drivers/staging/android/alarm-dev.c | 16 | ||||
| -rw-r--r-- | fs/timerfd.c | 16 |
2 files changed, 18 insertions, 14 deletions
diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c index 0324a4ea7..b2153af10 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -38,10 +38,10 @@ static int debug_mask = ANDROID_ALARM_PRINT_INFO; module_param_named(debug_mask, debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP); -#define alarm_dbg(debug_level_mask, fmt, args...) \ +#define alarm_dbg(debug_level_mask, fmt, args...) \ do { \ if (debug_mask & ANDROID_ALARM_PRINT_##debug_level_mask) \ - pr_debug(LOG_MYTAG fmt, ##args); \ + pr_debug(LOG_MYTAG fmt, ##args); \ } while (0) #define ANDROID_ALARM_WAKEUP_MASK ( \ @@ -133,8 +133,8 @@ static void alarm_set(enum android_alarm_type alarm_type, uint32_t alarm_type_mask = 1U << alarm_type; unsigned long flags; - alarm_dbg(INFO, "alarm %d set %ld.%09ld\n", - alarm_type, ts->tv_sec, ts->tv_nsec); + alarm_dbg(INFO, "alarm %d set %ld.%09ld\n", + alarm_type, ts->tv_sec, ts->tv_nsec); if (alarm_type == ANDROID_ALARM_POWER_ON) { alarm_set_power_on(*ts, false); return; @@ -232,7 +232,7 @@ static int alarm_get_time(enum android_alarm_type alarm_type, } static long alarm_do_ioctl(struct file *file, unsigned int cmd, - struct timespec *ts, struct rtc_wkalrm *alm) + struct timespec *ts, struct rtc_wkalrm *alm) { int rv = 0; unsigned long flags; @@ -244,9 +244,9 @@ static long alarm_do_ioctl(struct file *file, unsigned int cmd, return -EINVAL; } - if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_TIME(0) - && ANDROID_ALARM_BASE_CMD(cmd)!= ANDROID_ALARM_SET_IPO(0) - && ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_POWER_ON_IPO) { + if (ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_TIME(0) + && ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_SET_IPO(0) + && ANDROID_ALARM_BASE_CMD(cmd) != ANDROID_ALARM_GET_POWER_ON_IPO) { if ((file->f_flags & O_ACCMODE) == O_RDONLY) return -EPERM; if (file->private_data == NULL && diff --git a/fs/timerfd.c b/fs/timerfd.c index 7a1713fb7..683dba2a9 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -155,7 +155,7 @@ static ktime_t timerfd_get_remaining(struct timerfd_ctx *ctx) else remaining = hrtimer_expires_remaining(&ctx->t.tmr); - return remaining.tv64 < 0 ? ktime_set(0, 0): remaining; + return remaining.tv64 < 0 ? ktime_set(0, 0) : remaining; } static int timerfd_setup(struct timerfd_ctx *ctx, int flags, @@ -166,7 +166,7 @@ static int timerfd_setup(struct timerfd_ctx *ctx, int flags, int clockid = ctx->clockid; htmode = (flags & TFD_TIMER_ABSTIME) ? - HRTIMER_MODE_ABS: HRTIMER_MODE_REL; + HRTIMER_MODE_ABS : HRTIMER_MODE_REL; texp = timespec_to_ktime(ktmr->it_value); ctx->expired = 0; @@ -283,7 +283,7 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, } spin_unlock_irq(&ctx->wqh.lock); if (ticks) - res = put_user(ticks, (u64 __user *) buf) ? -EFAULT: sizeof(ticks); + res = put_user(ticks, (u64 __user *) buf) ? -EFAULT : sizeof(ticks); return res; } @@ -362,6 +362,7 @@ static const struct file_operations timerfd_fops = { static int timerfd_fget(int fd, struct fd *p) { struct fd f = fdget(fd); + if (!f.file) return -EBADF; if (f.file->f_op != &timerfd_fops) { @@ -414,7 +415,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) return ufd; } -static int do_timerfd_settime(int ufd, int flags, +static int do_timerfd_settime(int ufd, int flags, const struct itimerspec *new, struct itimerspec *old) { @@ -483,6 +484,7 @@ static int do_timerfd_gettime(int ufd, struct itimerspec *t) struct fd f; struct timerfd_ctx *ctx; int ret = timerfd_fget(ufd, &f); + if (ret) return ret; ctx = f.file->private_data; @@ -532,9 +534,10 @@ SYSCALL_DEFINE2(timerfd_gettime, int, ufd, struct itimerspec __user *, otmr) { struct itimerspec kotmr; int ret = do_timerfd_gettime(ufd, &kotmr); + if (ret) return ret; - return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT: 0; + return copy_to_user(otmr, &kotmr, sizeof(kotmr)) ? -EFAULT : 0; } #ifdef CONFIG_COMPAT @@ -560,8 +563,9 @@ COMPAT_SYSCALL_DEFINE2(timerfd_gettime, int, ufd, { struct itimerspec kotmr; int ret = do_timerfd_gettime(ufd, &kotmr); + if (ret) return ret; - return put_compat_itimerspec(otmr, &kotmr) ? -EFAULT: 0; + return put_compat_itimerspec(otmr, &kotmr) ? -EFAULT : 0; } #endif |
