From: Jean Delvare <khali@linux-fr.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
lm-sensors@lm-sensors.org, Hans de Goede <hdegoede@redhat.com>
Subject: Re: [lm-sensors] [patch 1/5] hwmon: Convert fschmd to unlocked_ioctl
Date: Fri, 6 Nov 2009 14:15:42 +0100 [thread overview]
Message-ID: <20091106141542.12404c5c@hyperion.delvare> (raw)
In-Reply-To: <20091015202758.400949170@linutronix.de>
Hi Thomas,
Sorry for the late answer.
On Thu, 15 Oct 2009 20:28:31 -0000, Thomas Gleixner wrote:
> The conversion of fschmd watchdog ioctl to unlocked_ioctl needs to
> protect the static watchdog_info variable for the WDIOC_GETSUPPORT
> command.
>
> All other commands are safe w/o BKL as the called watchdog functions
> are already serialized with watchdog_lock of the sensor.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: lm-sensors@lm-sensors.org
> ---
> drivers/hwmon/fschmd.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> Index: linux-2.6-tip/drivers/hwmon/fschmd.c
> ===================================================================
> --- linux-2.6-tip.orig/drivers/hwmon/fschmd.c
> +++ linux-2.6-tip/drivers/hwmon/fschmd.c
> @@ -844,8 +844,8 @@ static ssize_t watchdog_write(struct fil
> return count;
> }
>
> -static int watchdog_ioctl(struct inode *inode, struct file *filp,
> - unsigned int cmd, unsigned long arg)
> +static long watchdog_ioctl(struct file *filp, unsigned int cmd,
> + unsigned long arg)
> {
> static struct watchdog_info ident = {
> .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
> @@ -857,11 +857,13 @@ static int watchdog_ioctl(struct inode *
>
> switch (cmd) {
> case WDIOC_GETSUPPORT:
> + mutex_lock(&watchdog_data_mutex);
> ident.firmware_version = data->revision;
> if (!nowayout)
> ident.options |= WDIOF_MAGICCLOSE;
> if (copy_to_user((void __user *)arg, &ident, sizeof(ident)))
> ret = -EFAULT;
> + mutex_unlock(&watchdog_data_mutex);
> break;
I'm not sure why we need to hold the mutex here? My understanding is
that watchdog_data_mutex protects watchdog_data_list and each
watchdog's kref. And the above code doesn't touch either.
What I am more worried about is why ident is declared static. This
looks like a bug to me. Instead of abusing watchdog_data_mutex to
workaround this, I'd rather remove the "static". I guess that the
current code happens to work because neither data->revision nor
nowayout can change over time, but this looks needlessly fragile.
Hans, any comment?
>
> case WDIOC_GETSTATUS:
> @@ -921,7 +923,7 @@ static const struct file_operations watc
> .open = watchdog_open,
> .release = watchdog_release,
> .write = watchdog_write,
> - .ioctl = watchdog_ioctl,
> + .unlocked_ioctl = watchdog_ioctl,
> };
--
Jean Delvare
next prev parent reply other threads:[~2009-11-06 13:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 20:28 [patch 0/5] BKL another bunch Thomas Gleixner
2009-10-15 20:28 ` [patch 1/5] hwmon: Convert fschmd to unlocked_ioctl Thomas Gleixner
2009-11-06 13:15 ` Jean Delvare [this message]
2009-11-06 13:22 ` [lm-sensors] " Arnd Bergmann
2009-11-06 13:31 ` Jean Delvare
2009-11-06 13:36 ` Hans de Goede
2009-11-06 13:37 ` Arnd Bergmann
2009-11-06 13:35 ` Hans de Goede
2009-11-06 15:56 ` Thomas Gleixner
2009-12-17 13:12 ` Jean Delvare
2009-10-15 20:28 ` [patch 2/5] macintosh: Remove BKL from nvram driver Thomas Gleixner
2009-10-15 20:28 ` [patch 3/5] sunrpc: Convert to unlocked_ioctl and remove stray smp_lock.h Thomas Gleixner
2009-10-15 20:28 ` [patch 4/5] mtd: Remove BKL and convert to unlocked_ioctl Thomas Gleixner
2009-10-16 6:44 ` Artem Bityutskiy
2009-10-20 5:27 ` Thomas Gleixner
2009-10-15 20:28 ` [patch 5/5] bluetooth: Remove stub ioctl in hci_vhci Thomas Gleixner
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=20091106141542.12404c5c@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arnd@arndb.de \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=tglx@linutronix.de \
/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