qcom_geni_fw_initialise() only populates the GENI wrapper's private
data (fw) if it finds a firmware partition at EVT_LAST_STAGE_INIT. On
a board with no MMC/UFS storage and an unprovisioned SPI-NOR (before
any image has been flashed), it leaves fw NULL, and a later GENI
peripheral probe crashes dereferencing it in
qcom_geni_load_firmware().

Add a NULL check that returns -ENOENT instead, matching how the SPI
caller already handles a nonzero return from this function.

Signed-off-by: Vandhiadevan Karunamoorthy 
<[email protected]>
---
 drivers/misc/qcom_geni.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/misc/qcom_geni.c b/drivers/misc/qcom_geni.c
index d14d74e4216..f721385ea83 100644
--- a/drivers/misc/qcom_geni.c
+++ b/drivers/misc/qcom_geni.c
@@ -377,6 +377,10 @@ int qcom_geni_load_firmware(phys_addr_t qup_base,
 
        /* The firmware blob is the private data of the GENI wrapper (parent) */
        fw = dev_get_priv(dev->parent);
+       if (!fw) {
+               dev_err(dev, "QUP firmware not available\n");
+               return -ENOENT;
+       }
 
        ret = read_elf(&rsc, fw, &hdr);
        if (ret) {

-- 
2.34.1

Reply via email to