bus: mhi: core: Add missing checks for MMIO register entries
Subsystems (2)
PATCH v2 1/1 bus: mhi: core: Add missing checks for MMIO register entries
As per documentation, fields marked as (required) in an MHI controller structure need to be populated by the controller driver before calling mhi_register_controller(). Ensure all required pointers and non-zero fields are present in the controller before proceeding with registration.
--- drivers/bus/mhi/core/init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/bus/mhi/core/init.c +3 -4
@@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,u32 soc_info;int ret, i; -if (!mhi_cntrl) -return -EINVAL ; - -if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || +if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs || + !mhi_cntrl->fw_image || !mhi_cntrl->irq || + !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || !mhi_cntrl->status_cb || !mhi_cntrl->read_reg || !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)return -EINVAL ;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 17 lines · Bhaumik Bhatt
As per documentation, fields marked as (required) in an MHI controller structure need to be populated by the controller driver before calling
mhi_register_controller(). Ensure all required pointers and non-zero fields are present in the controller before proceeding with registration.Signed-off-by Bhaumik Bhatt <[email protected]>--- drivers/bus/mhi/core/init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/bus/mhi/core/init.c +0
-0
drivers/bus/mhi/core/init.c int mhi_register_controller(struct mhi_controller *mhi_cntrl, · line 883
Quoted 9 lines
drivers/bus/mhi/core/init.c +2
-4@@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,u32 soc_info;int ret, i; -if (!mhi_cntrl) -return -EINVAL ; - - if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || + if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs || + !mhi_cntrl->fw_image || !mhi_cntrl->irq ||
Can we make fw_image optional, not all MHI devices are flashless, some directly boot into AMSS without firmware loading.
Quoted 8 lines
drivers/bus/mhi/core/init.c +1
-1+ !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || !mhi_cntrl->status_cb || !mhi_cntrl->read_reg || !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs) return -EINVAL; --The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 22 lines · Loic Poulain
Quoted 21 lines · Bhaumik Bhatt
As per documentation, fields marked as (required) in an MHI controller structure need to be populated by the controller driver before calling
mhi_register_controller(). Ensure all required pointers and non-zero fields are present in the controller before proceeding with registration.Signed-off-by Bhaumik Bhatt <[email protected]>--- drivers/bus/mhi/core/init.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/bus/mhi/core/init.c +0
-0@@ -879,10 +879,9 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, u32 soc_info;int ret, i;
Quoted 10 lines
drivers/bus/mhi/core/init.c int mhi_register_controller(struct mhi_controller *mhi_cntrl, · line 883
Quoted 6 lines
drivers/bus/mhi/core/init.c +2
-4-if (!mhi_cntrl) -return -EINVAL ; - - if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || + if (!mhi_cntrl || !mhi_cntrl->cntrl_dev || !mhi_cntrl->regs || + !mhi_cntrl->fw_image || !mhi_cntrl->irq ||Can we make
fw_imageoptional, not all MHI devices are flashless, some directly boot into AMSS without firmware loading.
Haha. Just as I posted this, I thought of the same thing. I agree. v3 incoming.
Also, that patch will be a separate one so I can just remove FW image from here and post the patch to make FW image optional.
Quoted 8 lines
Quoted 8 lines
drivers/bus/mhi/core/init.c +1
-0+ !mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put || !mhi_cntrl->status_cb || !mhi_cntrl->read_reg || !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)return -EINVAL;--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project