Skip to content

Commit 47e339c

Browse files
quic-bjorandeandersson
authored andcommitted
soc: qcom: mdt_loader: Actually use the e_phoff
Rather than relying/assuming that the tools generating the firmware places the program headers immediately following the ELF header, use e_phoff as intended to find the program headers. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com> Link: https://lore.kernel.org/r/20250610-mdt-loader-validation-and-fixes-v2-3-f7073e9ab899@oss.qualcomm.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent cd84036 commit 47e339c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/soc/qcom/mdt_loader.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
117117
return -EINVAL;
118118

119119
ehdr = (struct elf32_hdr *)fw->data;
120-
phdrs = (struct elf32_phdr *)(ehdr + 1);
120+
phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);
121121

122122
for (i = 0; i < ehdr->e_phnum; i++) {
123123
phdr = &phdrs[i];
@@ -172,7 +172,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len,
172172
return ERR_PTR(-EINVAL);
173173

174174
ehdr = (struct elf32_hdr *)fw->data;
175-
phdrs = (struct elf32_phdr *)(ehdr + 1);
175+
phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);
176176

177177
if (ehdr->e_phnum < 2)
178178
return ERR_PTR(-EINVAL);
@@ -255,7 +255,7 @@ int qcom_mdt_pas_init(struct device *dev, const struct firmware *fw,
255255
return -EINVAL;
256256

257257
ehdr = (struct elf32_hdr *)fw->data;
258-
phdrs = (struct elf32_phdr *)(ehdr + 1);
258+
phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);
259259

260260
for (i = 0; i < ehdr->e_phnum; i++) {
261261
phdr = &phdrs[i];
@@ -310,7 +310,7 @@ static bool qcom_mdt_bins_are_split(const struct firmware *fw, const char *fw_na
310310
int i;
311311

312312
ehdr = (struct elf32_hdr *)fw->data;
313-
phdrs = (struct elf32_phdr *)(ehdr + 1);
313+
phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);
314314

315315
for (i = 0; i < ehdr->e_phnum; i++) {
316316
/*
@@ -355,7 +355,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
355355

356356
is_split = qcom_mdt_bins_are_split(fw, fw_name);
357357
ehdr = (struct elf32_hdr *)fw->data;
358-
phdrs = (struct elf32_phdr *)(ehdr + 1);
358+
phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff);
359359

360360
for (i = 0; i < ehdr->e_phnum; i++) {
361361
phdr = &phdrs[i];

0 commit comments

Comments
 (0)