summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-09-27 09:16:54 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-27 10:47:48 +0200
commitee5e8d812ca25bf95a97b4368aec4e680678e75e (patch)
treebf95e66764709d7785499e85937e805e77833d11 /drivers/nfc
parentfe235b58d517d623bf6d40c77afca1b0ee6fc85d (diff)
downloadlinux-ee5e8d812ca25bf95a97b4368aec4e680678e75e.tar.gz
linux-ee5e8d812ca25bf95a97b4368aec4e680678e75e.tar.bz2
linux-ee5e8d812ca25bf95a97b4368aec4e680678e75e.zip
NFC: Fix missing mutex unlock in pn533_send_cmd_frame_async
If command allocation failed cmd_lock was not released and deadlock would occur. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/pn533.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index d123444404c8..97c440a8cd61 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -716,7 +716,7 @@ static int pn533_send_cmd_frame_async(struct pn533 *dev,
void *arg, gfp_t flags)
{
struct pn533_cmd *cmd;
- int rc;
+ int rc = 0;
nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
@@ -729,16 +729,16 @@ static int pn533_send_cmd_frame_async(struct pn533 *dev,
if (!rc)
dev->cmd_pending = 1;
- mutex_unlock(&dev->cmd_lock);
-
- return rc;
+ goto unlock;
}
nfc_dev_dbg(&dev->interface->dev, "%s Queueing command", __func__);
cmd = kzalloc(sizeof(struct pn533_cmd), flags);
- if (!cmd)
- return -ENOMEM;
+ if (!cmd) {
+ rc = -ENOMEM;
+ goto unlock;
+ }
INIT_LIST_HEAD(&cmd->queue);
cmd->out_frame = out_frame;
@@ -750,9 +750,10 @@ static int pn533_send_cmd_frame_async(struct pn533 *dev,
list_add_tail(&cmd->queue, &dev->cmd_queue);
+unlock:
mutex_unlock(&dev->cmd_lock);
- return 0;
+ return rc;
}
struct pn533_sync_cmd_response {