From: Ahsan Atta <ahsan.atta@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com,
Ahsan Atta <ahsan.atta@intel.com>,
Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
Thomas Huth <thuth@redhat.com>
Subject: [PATCH RESEND] crypto: qat - clear fw_loader pointer on adf_ae_init() failure
Date: Fri, 13 Nov 2026 14:55:08 +0000 [thread overview]
Message-ID: <20261113145508.1556307-1-ahsan.atta@intel.com> (raw)
adf_ae_init() stores the newly allocated loader data in
accel_dev->fw_loader before calling qat_hal_init(), as the latter
publishes the HAL handle through that pointer. If either
qat_hal_init() or adf_ae_reset() fails, the error paths free the
allocation but leave accel_dev->fw_loader pointing at freed memory,
so the device is left holding a dangling pointer.
No code path dereferences that stale pointer today. This is therefore
a robustness improvement with no observable failure behind it, hence
no Fixes tag.
Clear accel_dev->fw_loader when the allocation is released, and fold
the duplicated error handling into a cascading goto chain. Report the
error returned by the callee rather than a generic -EFAULT;
adf_dev_init() still maps any failure to -EFAULT, so this is a
readability improvement and not a functional change.
Signed-off-by: Ahsan Atta <ahsan.atta@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
---
.../intel/qat/qat_common/adf_accel_engine.c | 21 ++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/intel/qat/qat_common/adf_accel_engine.c b/drivers/crypto/intel/qat/qat_common/adf_accel_engine.c
index bb97bbedbb8a..2db74b055201 100644
--- a/drivers/crypto/intel/qat/qat_common/adf_accel_engine.c
+++ b/drivers/crypto/intel/qat/qat_common/adf_accel_engine.c
@@ -181,6 +181,7 @@ int adf_ae_init(struct adf_accel_dev *accel_dev)
{
struct adf_fw_loader_data *loader_data;
struct adf_hw_device_data *hw_device = accel_dev->hw_device;
+ int ret;
if (!hw_device->fw_name)
return 0;
@@ -190,18 +191,24 @@ int adf_ae_init(struct adf_accel_dev *accel_dev)
return -ENOMEM;
accel_dev->fw_loader = loader_data;
- if (qat_hal_init(accel_dev)) {
+ ret = qat_hal_init(accel_dev);
+ if (ret) {
dev_err(&GET_DEV(accel_dev), "Failed to init the AEs\n");
- kfree(loader_data);
- return -EFAULT;
+ goto err_free_loader_data;
}
- if (adf_ae_reset(accel_dev, 0)) {
+ ret = adf_ae_reset(accel_dev, 0);
+ if (ret) {
dev_err(&GET_DEV(accel_dev), "Failed to reset the AEs\n");
- qat_hal_deinit(loader_data->fw_loader);
- kfree(loader_data);
- return -EFAULT;
+ goto err_hal_deinit;
}
return 0;
+
+err_hal_deinit:
+ qat_hal_deinit(loader_data->fw_loader);
+err_free_loader_data:
+ kfree(loader_data);
+ accel_dev->fw_loader = NULL;
+ return ret;
}
void adf_ae_shutdown(struct adf_accel_dev *accel_dev)
base-commit: 8ba9044ff0bf4a5789216496019fad614eeafd45
--
2.50.1
reply other threads:[~2026-11-13 14:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113145508.1556307-1-ahsan.atta@intel.com \
--to=ahsan.atta@intel.com \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=qat-linux@intel.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox