Commit 8c4cef464b90b1638ff01a922d6a34095cc09c0c
Committed by
Herbert Xu
1 parent
41a84982a1
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
crypto: qat - fix bad unlock balance
The mutex table_lock is unlocked in two functions without first being locked. Fix the functions to properly protect the accel_table with the table_lock. Also, fix a spelling error in one of the function's header comment. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 5 additions and 1 deletions Side-by-side Diff
drivers/crypto/qat/qat_common/adf_dev_mgr.c
... | ... | @@ -129,12 +129,13 @@ |
129 | 129 | * Function returns acceleration device associated with the given pci device. |
130 | 130 | * To be used by QAT device specific drivers. |
131 | 131 | * |
132 | - * Return: pinter to accel_dev or NULL if not found. | |
132 | + * Return: pointer to accel_dev or NULL if not found. | |
133 | 133 | */ |
134 | 134 | struct adf_accel_dev *adf_devmgr_pci_to_accel_dev(struct pci_dev *pci_dev) |
135 | 135 | { |
136 | 136 | struct list_head *itr; |
137 | 137 | |
138 | + mutex_lock(&table_lock); | |
138 | 139 | list_for_each(itr, &accel_table) { |
139 | 140 | struct adf_accel_dev *ptr = |
140 | 141 | list_entry(itr, struct adf_accel_dev, list); |
... | ... | @@ -144,6 +145,7 @@ |
144 | 145 | return ptr; |
145 | 146 | } |
146 | 147 | } |
148 | + mutex_unlock(&table_lock); | |
147 | 149 | return NULL; |
148 | 150 | } |
149 | 151 | EXPORT_SYMBOL_GPL(adf_devmgr_pci_to_accel_dev); |
... | ... | @@ -152,6 +154,7 @@ |
152 | 154 | { |
153 | 155 | struct list_head *itr; |
154 | 156 | |
157 | + mutex_lock(&table_lock); | |
155 | 158 | list_for_each(itr, &accel_table) { |
156 | 159 | struct adf_accel_dev *ptr = |
157 | 160 | list_entry(itr, struct adf_accel_dev, list); |
... | ... | @@ -161,6 +164,7 @@ |
161 | 164 | return ptr; |
162 | 165 | } |
163 | 166 | } |
167 | + mutex_unlock(&table_lock); | |
164 | 168 | return NULL; |
165 | 169 | } |
166 | 170 |