lkml.org 
[lkml]   [2019]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 16/21] PCI: endpoint: Fix missing mutex_unlock in error case
Date
There is a missing mutex_unlock() in pci_epc_add_epf() in one of the
error scenarios. Fix it here.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
drivers/pci/endpoint/pci-epc-core.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 797e5d323998..33c745546a42 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -686,6 +686,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
{
struct list_head *list;
u32 func_no = 0;
+ int ret = 0;

if (epf->is_vf)
return -EINVAL;
@@ -705,8 +706,10 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
mutex_lock(&epc->lock);
func_no = find_first_zero_bit(&epc->function_num_map,
BITS_PER_LONG);
- if (func_no >= BITS_PER_LONG)
- return -EINVAL;
+ if (func_no >= BITS_PER_LONG) {
+ ret = -EINVAL;
+ goto err;
+ }

set_bit(func_no, &epc->function_num_map);
if (type == PRIMARY_INTERFACE) {
@@ -720,9 +723,11 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
}

list_add_tail(list, &epc->pci_epf);
+
+err:
mutex_unlock(&epc->lock);

- return 0;
+ return ret;
}
EXPORT_SYMBOL_GPL(pci_epc_add_epf);

--
2.17.1
\
 
 \ /
  Last update: 2019-09-26 13:33    [W:0.114 / U:3.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site