[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4747B3F0.2020705@gmail.com>
Date: Sat, 24 Nov 2007 06:17:36 +0100
From: Michael Kerrisk <mtk.manpages@...glemail.com>
To: Davide Libenzi <davidel@...ilserver.org>
CC: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Michael Kerrisk <mtk-manpages@....net>,
Thomas Gleixner <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [patch 2/4] Timerfd v2 - new timerfd API
Hi Davide,
[...]
> +asmlinkage long sys_timerfd_create(int clockid, int flags)
> {
> - int error;
> + int error, ufd;
> struct timerfd_ctx *ctx;
> struct file *file;
> struct inode *inode;
> - struct itimerspec ktmr;
> -
> - if (copy_from_user(&ktmr, utmr, sizeof(ktmr)))
> - return -EFAULT;
>
> if (clockid != CLOCK_MONOTONIC &&
> clockid != CLOCK_REALTIME)
> return -EINVAL;
Could I suggest here, the following placeholder addition:
if (flags != 0)
return -EINVAL;
Later than can replaced with something like:
if (flags & ~(O_NONBLOCK | O_CLOEXEC))
return -EINVAL;
Having the first of the checks above will allow userland to determine what
is implemented, rather than having non-zero flags silently ignored.
Cheers,
Michael
> + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> + if (!ctx)
> + return -ENOMEM;
> +
> + init_waitqueue_head(&ctx->wqh);
> + ctx->clockid = clockid;
> + hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS);
> +
> + error = anon_inode_getfd(&ufd, &inode, &file, "[timerfd]",
> + &timerfd_fops, ctx);
> + if (error) {
> + kfree(ctx);
> + return error;
> + }
> +
> + return ufd;
> +}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists