diff mbox series

soc: qcom: ocmem: don't return NULL in of_get_ocmem

Message ID 20210130142349.53335-1-luca@z3ntu.xyz
State Accepted
Commit 01f937ffc4686837d6c43dea80c6ade6cbd2940a
Headers show
Series soc: qcom: ocmem: don't return NULL in of_get_ocmem | expand

Commit Message

Luca Weiss Jan. 30, 2021, 2:23 p.m. UTC
If ocmem probe fails for whatever reason, of_get_ocmem returned NULL.
Without this, users must check for both NULL and IS_ERR on the returned
pointer - which didn't happen in drivers/gpu/drm/msm/adreno/adreno_gpu.c
leading to a NULL pointer dereference.

Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")
Signed-off-by: Luca Weiss <luca@z3ntu.xyz>
---
 drivers/soc/qcom/ocmem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

patchwork-bot+linux-arm-msm@kernel.org Feb. 2, 2021, 11:10 p.m. UTC | #1
Hello:

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

On Sat, 30 Jan 2021 15:23:49 +0100 you wrote:
> If ocmem probe fails for whatever reason, of_get_ocmem returned NULL.

> Without this, users must check for both NULL and IS_ERR on the returned

> pointer - which didn't happen in drivers/gpu/drm/msm/adreno/adreno_gpu.c

> leading to a NULL pointer dereference.

> 

> Fixes: 88c1e9404f1d ("soc: qcom: add OCMEM driver")

> Signed-off-by: Luca Weiss <luca@z3ntu.xyz>

> 

> [...]


Here is the summary with links:
  - soc: qcom: ocmem: don't return NULL in of_get_ocmem
    https://git.kernel.org/qcom/c/01f937ffc468

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

Patch

diff --git a/drivers/soc/qcom/ocmem.c b/drivers/soc/qcom/ocmem.c
index 7f9e9944d1ea..f1875dc31ae2 100644
--- a/drivers/soc/qcom/ocmem.c
+++ b/drivers/soc/qcom/ocmem.c
@@ -189,6 +189,7 @@  struct ocmem *of_get_ocmem(struct device *dev)
 {
 	struct platform_device *pdev;
 	struct device_node *devnode;
+	struct ocmem *ocmem;
 
 	devnode = of_parse_phandle(dev->of_node, "sram", 0);
 	if (!devnode || !devnode->parent) {
@@ -202,7 +203,12 @@  struct ocmem *of_get_ocmem(struct device *dev)
 		return ERR_PTR(-EPROBE_DEFER);
 	}
 
-	return platform_get_drvdata(pdev);
+	ocmem = platform_get_drvdata(pdev);
+	if (!ocmem) {
+		dev_err(dev, "Cannot get ocmem\n");
+		return ERR_PTR(-ENODEV);
+	}
+	return ocmem;
 }
 EXPORT_SYMBOL(of_get_ocmem);