Commit 28cd8db6 authored by Bjorn Andersson's avatar Bjorn Andersson Committed by Greg Kroah-Hartman

remoteproc: qcom: mdt_loader: Don't overwrite firmware object

commit 3e8b571a upstream.

The "fw" firmware object is passed from the remoteproc core and should
not be overwritten, as that results in leaked buffers and a double free
of the the last firmware object.

Fixes: 051fb70f ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8e2b7672
...@@ -116,6 +116,7 @@ int qcom_mdt_load(struct rproc *rproc, ...@@ -116,6 +116,7 @@ int qcom_mdt_load(struct rproc *rproc,
const struct elf32_phdr *phdrs; const struct elf32_phdr *phdrs;
const struct elf32_phdr *phdr; const struct elf32_phdr *phdr;
const struct elf32_hdr *ehdr; const struct elf32_hdr *ehdr;
const struct firmware *seg_fw;
size_t fw_name_len; size_t fw_name_len;
char *fw_name; char *fw_name;
void *ptr; void *ptr;
...@@ -154,16 +155,16 @@ int qcom_mdt_load(struct rproc *rproc, ...@@ -154,16 +155,16 @@ int qcom_mdt_load(struct rproc *rproc,
if (phdr->p_filesz) { if (phdr->p_filesz) {
sprintf(fw_name + fw_name_len - 3, "b%02d", i); sprintf(fw_name + fw_name_len - 3, "b%02d", i);
ret = request_firmware(&fw, fw_name, &rproc->dev); ret = request_firmware(&seg_fw, fw_name, &rproc->dev);
if (ret) { if (ret) {
dev_err(&rproc->dev, "failed to load %s\n", dev_err(&rproc->dev, "failed to load %s\n",
fw_name); fw_name);
break; break;
} }
memcpy(ptr, fw->data, fw->size); memcpy(ptr, seg_fw->data, seg_fw->size);
release_firmware(fw); release_firmware(seg_fw);
} }
if (phdr->p_memsz > phdr->p_filesz) if (phdr->p_memsz > phdr->p_filesz)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment