public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: "Andrew Victor" <avictor.za@gmail.com>
Cc: akpm@linux-foundation.org, wim@iguana.be,
	LAK <linux-arm-kernel@lists.arm.linux.org.uk>,
	"Linux Kernel list" <linux-kernel@vger.kernel.org>
Subject: Re: AT91SAM9/CAP9 watchdog driver
Date: Mon, 2 Jun 2008 07:58:08 +0100	[thread overview]
Message-ID: <20080602075808.3b854855@core> (raw)
In-Reply-To: <cd73a99e0806010940g501f11b4jcb7caf6acfd5c49f@mail.gmail.com>


> +static long at91_wdt_ioctl(struct file *file, unsigned int cmd,
> +		unsigned long arg)
> +{
> +	void __user *argp = (void __user *)arg;
> +	int __user *p = argp;

No locking.. so you could get two set timeout calls in parallel. Probably
you need a simple mutex in at91_wdt_settimeout();


> +	res = misc_register(&at91wdt_miscdev);
> +	if (res)
> +		return res;
> +
> +	/* Set watchdog */
> +	if (at91_wdt_settimeout(wdt_timeout) == -EINVAL) {
> +		pr_info("at91sam9_wdt: timeout must be between 1 and %d.\n",
> +			WDT_MAX_TIME);
> +		return 0;

At the moment those two are safe. When the open lock_kernel
goes away it will be possible to get

			misc_register
						open
						ioctl
			wdt_settimout()

So you may want to swap those two around (and disable the timer if the
register fails ?), or lock the open against the register routine.

Otherwise looks good.

Alan

  reply	other threads:[~2008-06-02  7:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-01 16:40 AT91SAM9/CAP9 watchdog driver Andrew Victor
2008-06-02  6:58 ` Alan Cox [this message]
2008-06-03 21:23 ` Andrew Morton
2008-06-04  7:31   ` Andrew Victor
2008-06-04 11:36     ` Alan Cox
2008-06-04 18:36       ` Andrew Victor
2008-06-04 18:24         ` Alan Cox
2008-06-04 19:02           ` Andrew Victor
2008-06-04 19:18             ` Alan Cox
2008-06-07  6:39 ` David Brownell

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=20080602075808.3b854855@core \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=avictor.za@gmail.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wim@iguana.be \
    /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