All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Michael Brumlow <mbrumlow@gmail.com>
Cc: tobiasa@axis.com, linux-kernel@vger.kernel.org
Subject: [PATCH] cris: fix locking in pcf8563.c
Date: Wed, 9 Mar 2011 12:55:28 +0100	[thread overview]
Message-ID: <201103091255.28510.arnd@arndb.de> (raw)
In-Reply-To: <AANLkTi=kQGB0YKOunpEEy8xQqM7UCRSCwGqWC5TxJHY8@mail.gmail.com>

The ioctl function was incorrectly converted to unlocked_ioctl,
this fixes the locking.

Reported-by: Michael Brumlow <mbrumlow@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
On Wednesday 09 March 2011, Michael Brumlow wrote:

> I was looking through some code and found an issue in the driver you
> wrote. The problem can be found in
> "arch/cris/arch-v10/drivers/pcf8563.c" function
> "pcf8563_unlocked_ioctl". The function locks a mutex and returns, when
> it should be locking the locking the mutex, storing the return from
> the function called and then unlocking the mutex and finally returning
> the stored value of the function called.
> 
> # in its current state.
>  343 static long pcf8563_unlocked_ioctl(struct file *filp, unsigned
> int cmd, unsigned long arg)
>  344 {
>  345         int ret;
>  346
>  347         mutex_lock(&pcf8563_mutex);
>  348         return pcf8563_ioctl(filp, cmd, arg);
>  349         mutex_unlock(&pcf8563_mutex);
>  350
>  351         return ret;
>  352 }
> 
> # what is suggested.
>  343 static long pcf8563_unlocked_ioctl(struct file *filp, unsigned
> int cmd, unsigned long arg)
>  344 {
>  345         int ret;
>  346
>  347         mutex_lock(&pcf8563_mutex);
>  348         ret = pcf8563_ioctl(filp, cmd, arg);
>  349         mutex_unlock(&pcf8563_mutex);
>  350
>  351         return ret;
>  352 }

You are right. This problem exists in both arch/cris/arch-v10/drivers/pcf8563.c
and arch/cris/arch-v32/drivers/pcf8563.c, and apparently both are my fault.

	Arnd
---
diff --git a/arch/cris/arch-v10/drivers/pcf8563.c b/arch/cris/arch-v10/drivers/pcf8563.c
index ea69fab..1391b73 100644
--- a/arch/cris/arch-v10/drivers/pcf8563.c
+++ b/arch/cris/arch-v10/drivers/pcf8563.c
@@ -345,7 +345,7 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
 	int ret;
 
 	mutex_lock(&pcf8563_mutex);
-	return pcf8563_ioctl(filp, cmd, arg);
+	ret = pcf8563_ioctl(filp, cmd, arg);
 	mutex_unlock(&pcf8563_mutex);
 
 	return ret;
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
index b6e4fc0..208594f 100644
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ b/arch/cris/arch-v32/drivers/pcf8563.c
@@ -341,7 +341,7 @@ static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
 	int ret;
 
 	mutex_lock(&pcf8563_mutex);
-	return pcf8563_ioctl(filp, cmd, arg);
+	ret = pcf8563_ioctl(filp, cmd, arg);
 	mutex_unlock(&pcf8563_mutex);
 
 	return ret;

           reply	other threads:[~2011-03-09 11:55 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <AANLkTi=kQGB0YKOunpEEy8xQqM7UCRSCwGqWC5TxJHY8@mail.gmail.com>]

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=201103091255.28510.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbrumlow@gmail.com \
    --cc=tobiasa@axis.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.