@@ -99,7 +99,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
return ERR_PTR(-EINVAL);
if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD)
- return ERR_PTR(-EINVAL);
+ goto return_fw_copy;
if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH)
return ERR_PTR(-EINVAL);
@@ -123,6 +123,18 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
*data_len = ehdr_size + hash_size;
return data;
+
+return_fw_copy:
+ /*
+ * Some older firmware (e.g. on 8974) doesn't have a hash segment
+ * following the ELF header, just return a verbatim copy of the
+ * fw->data and let the metadata authenticator consume what it needs.
+ */
+ data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+ if (!data)
+ return ERR_PTR(-ENOMEM);
+ *data_len = fw->size;
+ return data;
}
EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);
At least some of the firmware found on 8974 does not follow the typical scheme of having a non-loadable hash segment directly following the ELF header, in the modem mdt. Rather than failing the read of metadata, fall back to passing back a copy of the full first firmware file and let the metadata validator do its job. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> --- drivers/soc/qcom/mdt_loader.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) -- 2.23.0