soc: qcom: mdt_loader: Extend check for split firmware
authorBjorn Andersson <bjorn.andersson@linaro.org>
Fri, 28 Jan 2022 02:55:05 +0000 (18:55 -0800)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Thu, 3 Feb 2022 21:32:30 +0000 (15:32 -0600)
Some of the Qualcomm SM8450 firmware files are padded such that the
start of the first segment falls within the .mdt file but the segment to
be loaded is stored as a separate .bNN file.

Extend the condition to only attempt to read a segment inline if the
entire segment would be available.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20220128025513.97188-6-bjorn.andersson@linaro.org
drivers/soc/qcom/mdt_loader.c

index c5bd13b05c1ad31d2bf192551541f78d501bcfd1..37e2e734bc5dfb4ea23882e73c59350b412be818 100644 (file)
@@ -297,7 +297,8 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
 
                ptr = mem_region + offset;
 
-               if (phdr->p_filesz && phdr->p_offset < fw->size) {
+               if (phdr->p_filesz && phdr->p_offset < fw->size &&
+                   phdr->p_offset + phdr->p_filesz < fw->size) {
                        /* Firmware is large enough to be non-split */
                        if (phdr->p_offset + phdr->p_filesz > fw->size) {
                                dev_err(dev, "file %s segment %d would be truncated\n",