Skip to contentSkip to conversation

remoteproc: k3-dsp: Fix return value check in k3_dsp_rproc_of_get_memories()

PATCH Superseded YueHaibing 4 participants 7 messages Sep 2, 2020 – Nov 18, 2020 Remote processor (remoteproc)

lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 remoteproc: k3-dsp: Fix return value check in k3_dsp_rproc_of_get_memories()

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 87218f96c21a ("remoteproc: k3-dsp: Add support for C71x DSPs")
---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
index 9011e477290c..f373df35d7d0 100644
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -EBUSY;
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · YueHaibing

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Thanks for the fix.

Quoted 2 lines
Fixes 87218f96c21a ("remoteproc: k3-dsp: Add support for C71x DSPs")

This should instead be

Fixes 6edbe024ba17 ("remoteproc: k3-dsp: Add a remoteproc driver of K3 C66x DSPs")

With that,

Quoted 23 lines
---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
index 9011e477290c..f373df35d7d0 100644
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -EBUSY;
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
maintainer
#2 lore raw
In reply to YueHaibing
Quoted 15 lines · YueHaibing

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 87218f96c21a ("remoteproc: k3-dsp: Add support for C71x DSPs")
---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -0
index 9011e477290c..f373df35d7d0 100644

drivers/remoteproc/ti_k3_dsp_remoteproc.c static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev, · line 451

Quoted 9 lines
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -EBUSY;

Shouldn't this be -ENOMEM?

Quoted 7 lines
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -0
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
Signature · 1 line
2.17.1
#3 lore raw
Quoted 17 lines · Mathieu Poirier
Quoted 16 lines · YueHaibing

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 87218f96c21a ("remoteproc: k3-dsp: Add support for C71x DSPs")
---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -0
index 9011e477290c..f373df35d7d0 100644
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
Quoted 10 lines

drivers/remoteproc/ti_k3_dsp_remoteproc.c static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev, · line 451

Quoted 8 lines
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -EBUSY;

Shouldn't this be -ENOMEM?

Indeed, thanks for catching it.

I will fix these same issues on the K3 R5F driver for v4.

regards
Suman

Quoted 8 lines
Quoted 8 lines
drivers/remoteproc/ti_k3_dsp_remoteproc.c +0 -0
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v2 1/1 remoteproc: k3-dsp: Fix return value check in k3_dsp_rproc_of_get_memories()

In reply to YueHaibing

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 6edbe024ba17 ("remoteproc: k3-dsp: Add a remoteproc driver of K3 C66x DSPs")

---
v2: return ENOMEM instead of EBUSY, use corret Fixes tag

---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
index 9011e477290c..f373df35d7d0 100644
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -ENOMEM;
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#5 lore raw
Quoted 7 lines · YueHaibing

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 6edbe024ba17 ("remoteproc: k3-dsp: Add a remoteproc driver of K3 C66x DSPs")
Quoted 27 lines

---
v2: return ENOMEM instead of EBUSY, use corret Fixes tag

---
 drivers/remoteproc/ti_k3_dsp_remoteproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/ti_k3_dsp_remoteproc.c +2 -2
index 9011e477290c..f373df35d7d0 100644
@@ -445,10 +445,10 @@ static int k3_dsp_rproc_of_get_memories(struct platform_device *pdev,
 
 		kproc->mem[i].cpu_addr = devm_ioremap_wc(dev, res->start,
 							 resource_size(res));
-		if (IS_ERR(kproc->mem[i].cpu_addr)) {
+		if (!kproc->mem[i].cpu_addr) {
 			dev_err(dev, "failed to map %s memory\n",
 				data->mems[i].name);
-			return PTR_ERR(kproc->mem[i].cpu_addr);
+			return -ENOMEM;
 		}
 		kproc->mem[i].bus_addr = res->start;
 		kproc->mem[i].dev_addr = data->mems[i].dev_addr;
Signature · 1 line
2.17.1
#6 lore raw
In reply to YueHaibing
This patch was applied to andersson/remoteproc.git (refs/heads/for-next):

Hello:

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

Quoted 9 lines · On Sat, 5 Sep 2020 20:25:03 +0800 you wrote:

In case of error, the function devm_ioremap_wc() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test.

Fixes 6edbe024ba17 ("remoteproc: k3-dsp: Add a remoteproc driver of K3 C66x DSPs")

[...]

Here is the summary with links:
- [v2,-next] remoteproc: k3-dsp: Fix return value check in k3_dsp_rproc_of_get_memories()

    https://git.kernel.org/andersson/remoteproc/c/9b3b3c9531e8

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