aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2012-09-27 03:16:54 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-27 04:47:48 -0400
commitee5e8d812ca25bf95a97b4368aec4e680678e75e (patch)
treebf95e66764709d7785499e85937e805e77833d11 /drivers/nfc
parentfe235b58d517d623bf6d40c77afca1b0ee6fc85d (diff)
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,
716 void *arg, gfp_t flags) 716 void *arg, gfp_t flags)
717{ 717{
718 struct pn533_cmd *cmd; 718 struct pn533_cmd *cmd;
719 int rc; 719 int rc = 0;
720 720
721 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 721 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
722 722
@@ -729,16 +729,16 @@ static int pn533_send_cmd_frame_async(struct pn533 *dev,
729 if (!rc) 729 if (!rc)
730 dev->cmd_pending = 1; 730 dev->cmd_pending = 1;
731 731
732 mutex_unlock(&dev->cmd_lock); 732 goto unlock;
733
734 return rc;
735 } 733 }
736 734
737 nfc_dev_dbg(&dev->interface->dev, "%s Queueing command", __func__); 735 nfc_dev_dbg(&dev->interface->dev, "%s Queueing command", __func__);
738 736
739 cmd = kzalloc(sizeof(struct pn533_cmd), flags); 737 cmd = kzalloc(sizeof(struct pn533_cmd), flags);
740 if (!cmd) 738 if (!cmd) {
741 return -ENOMEM; 739 rc = -ENOMEM;
740 goto unlock;
741 }
742 742
743 INIT_LIST_HEAD(&cmd->queue); 743 INIT_LIST_HEAD(&cmd->queue);
744 cmd->out_frame = out_frame; 744 cmd->out_frame = out_frame;
@@ -750,9 +750,10 @@ static int pn533_send_cmd_frame_async(struct pn533 *dev,
750 750
751 list_add_tail(&cmd->queue, &dev->cmd_queue); 751 list_add_tail(&cmd->queue, &dev->cmd_queue);
752 752
753unlock:
753 mutex_unlock(&dev->cmd_lock); 754 mutex_unlock(&dev->cmd_lock);
754 755
755 return 0; 756 return rc;
756} 757}
757 758
758struct pn533_sync_cmd_response { 759struct pn533_sync_cmd_response {