From: Michael Kerrisk <mtk.manpages@googlemail.com>
To: Davide Libenzi <davidel@xmailserver.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Michael Kerrisk <mtk-manpages@gmx.net>,
Thomas Gleixner <tglx@linutronix.de>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [patch 2/4] Timerfd v2 - new timerfd API
Date: Sat, 24 Nov 2007 06:17:36 +0100 [thread overview]
Message-ID: <4747B3F0.2020705@gmail.com> (raw)
In-Reply-To: <send-serie.davidel@xmailserver.org.6855.1195854702.2>
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;
> +}
next prev parent reply other threads:[~2007-11-24 5:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-23 21:51 [patch 2/4] Timerfd v2 - new timerfd API Davide Libenzi
2007-11-24 5:17 ` Michael Kerrisk [this message]
2007-11-24 20:52 ` Davide Libenzi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4747B3F0.2020705@gmail.com \
--to=mtk.manpages@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk-manpages@gmx.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox