diff options
author | Tadeusz Struk <tadeusz.struk@intel.com> | 2015-04-03 11:41:17 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-04-07 09:34:22 -0400 |
commit | b4e97050248d9cbf84a5fd023eb20c253b7ab35b (patch) | |
tree | 1bedf74072b77a25b54ec43275a7b10f46c279be /drivers/crypto | |
parent | 8b5cf097c3b0940f2be0d20dd16178405ebb63ec (diff) |
crypto: qat - fix double release_firmware on error path
release_firmware was called twice on error path causing an Oops.
Reported-by: Ahsan Atta <ahsan.atta@intel.com>
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_accel_engine.c | 14 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_common_drv.h | 2 | ||||
-rw-r--r-- | drivers/crypto/qat/qat_common/adf_init.c | 9 |
3 files changed, 13 insertions, 12 deletions
diff --git a/drivers/crypto/qat/qat_common/adf_accel_engine.c b/drivers/crypto/qat/qat_common/adf_accel_engine.c index 97e8ea5d928c..7f8b66c915ed 100644 --- a/drivers/crypto/qat/qat_common/adf_accel_engine.c +++ b/drivers/crypto/qat/qat_common/adf_accel_engine.c | |||
@@ -78,19 +78,22 @@ int adf_ae_fw_load(struct adf_accel_dev *accel_dev) | |||
78 | return 0; | 78 | return 0; |
79 | 79 | ||
80 | out_err: | 80 | out_err: |
81 | release_firmware(loader_data->uof_fw); | 81 | adf_ae_fw_release(accel_dev); |
82 | return -EFAULT; | 82 | return -EFAULT; |
83 | } | 83 | } |
84 | 84 | ||
85 | int adf_ae_fw_release(struct adf_accel_dev *accel_dev) | 85 | void adf_ae_fw_release(struct adf_accel_dev *accel_dev) |
86 | { | 86 | { |
87 | struct adf_fw_loader_data *loader_data = accel_dev->fw_loader; | 87 | struct adf_fw_loader_data *loader_data = accel_dev->fw_loader; |
88 | 88 | ||
89 | release_firmware(loader_data->uof_fw); | ||
90 | qat_uclo_del_uof_obj(loader_data->fw_loader); | 89 | qat_uclo_del_uof_obj(loader_data->fw_loader); |
91 | qat_hal_deinit(loader_data->fw_loader); | 90 | qat_hal_deinit(loader_data->fw_loader); |
91 | |||
92 | if (loader_data->uof_fw) | ||
93 | release_firmware(loader_data->uof_fw); | ||
94 | |||
95 | loader_data->uof_fw = NULL; | ||
92 | loader_data->fw_loader = NULL; | 96 | loader_data->fw_loader = NULL; |
93 | return 0; | ||
94 | } | 97 | } |
95 | 98 | ||
96 | int adf_ae_start(struct adf_accel_dev *accel_dev) | 99 | int adf_ae_start(struct adf_accel_dev *accel_dev) |
@@ -165,6 +168,9 @@ int adf_ae_init(struct adf_accel_dev *accel_dev) | |||
165 | 168 | ||
166 | int adf_ae_shutdown(struct adf_accel_dev *accel_dev) | 169 | int adf_ae_shutdown(struct adf_accel_dev *accel_dev) |
167 | { | 170 | { |
171 | struct adf_fw_loader_data *loader_data = accel_dev->fw_loader; | ||
172 | |||
173 | qat_hal_deinit(loader_data->fw_loader); | ||
168 | kfree(accel_dev->fw_loader); | 174 | kfree(accel_dev->fw_loader); |
169 | accel_dev->fw_loader = NULL; | 175 | accel_dev->fw_loader = NULL; |
170 | return 0; | 176 | return 0; |
diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h index a62e485c8786..0666ee6a3360 100644 --- a/drivers/crypto/qat/qat_common/adf_common_drv.h +++ b/drivers/crypto/qat/qat_common/adf_common_drv.h | |||
@@ -115,7 +115,7 @@ int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev); | |||
115 | int adf_ae_init(struct adf_accel_dev *accel_dev); | 115 | int adf_ae_init(struct adf_accel_dev *accel_dev); |
116 | int adf_ae_shutdown(struct adf_accel_dev *accel_dev); | 116 | int adf_ae_shutdown(struct adf_accel_dev *accel_dev); |
117 | int adf_ae_fw_load(struct adf_accel_dev *accel_dev); | 117 | int adf_ae_fw_load(struct adf_accel_dev *accel_dev); |
118 | int adf_ae_fw_release(struct adf_accel_dev *accel_dev); | 118 | void adf_ae_fw_release(struct adf_accel_dev *accel_dev); |
119 | int adf_ae_start(struct adf_accel_dev *accel_dev); | 119 | int adf_ae_start(struct adf_accel_dev *accel_dev); |
120 | int adf_ae_stop(struct adf_accel_dev *accel_dev); | 120 | int adf_ae_stop(struct adf_accel_dev *accel_dev); |
121 | 121 | ||
diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c index da5793b34841..245f43237a2d 100644 --- a/drivers/crypto/qat/qat_common/adf_init.c +++ b/drivers/crypto/qat/qat_common/adf_init.c | |||
@@ -160,7 +160,6 @@ int adf_dev_init(struct adf_accel_dev *accel_dev) | |||
160 | if (adf_ae_fw_load(accel_dev)) { | 160 | if (adf_ae_fw_load(accel_dev)) { |
161 | dev_err(&GET_DEV(accel_dev), | 161 | dev_err(&GET_DEV(accel_dev), |
162 | "Failed to load acceleration FW\n"); | 162 | "Failed to load acceleration FW\n"); |
163 | adf_ae_fw_release(accel_dev); | ||
164 | return -EFAULT; | 163 | return -EFAULT; |
165 | } | 164 | } |
166 | set_bit(ADF_STATUS_AE_UCODE_LOADED, &accel_dev->status); | 165 | set_bit(ADF_STATUS_AE_UCODE_LOADED, &accel_dev->status); |
@@ -359,12 +358,8 @@ void adf_dev_shutdown(struct adf_accel_dev *accel_dev) | |||
359 | } | 358 | } |
360 | 359 | ||
361 | if (test_bit(ADF_STATUS_AE_UCODE_LOADED, &accel_dev->status)) { | 360 | if (test_bit(ADF_STATUS_AE_UCODE_LOADED, &accel_dev->status)) { |
362 | if (adf_ae_fw_release(accel_dev)) | 361 | adf_ae_fw_release(accel_dev); |
363 | dev_err(&GET_DEV(accel_dev), | 362 | clear_bit(ADF_STATUS_AE_UCODE_LOADED, &accel_dev->status); |
364 | "Failed to release the ucode\n"); | ||
365 | else | ||
366 | clear_bit(ADF_STATUS_AE_UCODE_LOADED, | ||
367 | &accel_dev->status); | ||
368 | } | 363 | } |
369 | 364 | ||
370 | if (test_bit(ADF_STATUS_AE_INITIALISED, &accel_dev->status)) { | 365 | if (test_bit(ADF_STATUS_AE_INITIALISED, &accel_dev->status)) { |