Skip to contentSkip to conversation

bus: mhi: core: Add missing checks for MMIO register entries

PATCH Applied Bhaumik Bhatt 4 participants 6 messages Mar 9, 2021 – May 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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 the registration.

---
v3: removed fw_image as not all controllers require it
v2: removed iova_start and iova_stop as they can be zero

 drivers/bus/mhi/core/init.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/bus/mhi/core/init.c +3 -5
index 272f350..d8882b3 100644
@@ -879,12 +879,10 @@ 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->runtime_get || !mhi_cntrl->runtime_put ||
 	    !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
-	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
+	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs || !mhi_cntrl->irq)
 		return -EINVAL;
 
 	ret = parse_config(mhi_cntrl, config);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v3 1/1
#1 lore raw
Quoted 7 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 the registration.

Signature · 3 lines
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
Reviewed-by on v3 1/1
#2 lore raw
In reply to Bhaumik Bhatt
Quoted 8 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 the registration.

---

Signature · 3 lines
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
Reviewed-by on v3 1/1
#3 lore raw
In reply to Bhaumik Bhatt
Quoted 7 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 the registration.

Thanks,
Mani

Quoted 31 lines

---
v3: removed fw_image as not all controllers require it
v2: removed iova_start and iova_stop as they can be zero

 drivers/bus/mhi/core/init.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/bus/mhi/core/init.c +3 -5
index 272f350..d8882b3 100644
@@ -879,12 +879,10 @@ 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->runtime_get || !mhi_cntrl->runtime_put ||
 	    !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
-	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
+	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs || !mhi_cntrl->irq)
 		return -EINVAL;
 
 	ret = parse_config(mhi_cntrl, config);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#4 lore raw
In reply to Bhaumik Bhatt
Quoted 7 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 the registration.

Applied to mhi-next!

Thanks,
Mani

Quoted 31 lines

---
v3: removed fw_image as not all controllers require it
v2: removed iova_start and iova_stop as they can be zero

 drivers/bus/mhi/core/init.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/bus/mhi/core/init.c +3 -5
index 272f350..d8882b3 100644
@@ -879,12 +879,10 @@ 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->runtime_get || !mhi_cntrl->runtime_put ||
 	    !mhi_cntrl->status_cb || !mhi_cntrl->read_reg ||
-	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs)
+	    !mhi_cntrl->write_reg || !mhi_cntrl->nr_irqs || !mhi_cntrl->irq)
 		return -EINVAL;
 
 	ret = parse_config(mhi_cntrl, config);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw
In reply to Bhaumik Bhatt
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 9 lines · On Tue, 9 Mar 2021 10:44:50 -0800 you wrote:

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 the registration.

[...]

Here is the summary with links:
- [v3] bus: mhi: core: Add missing checks for MMIO register entries

    https://git.kernel.org/qcom/c/8de5ad994143

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html