Skip to contentSkip to conversation

remoteproc: Fix an error code in devm_rproc_alloc()

PATCH Applied Dan Carpenter 4 participants 4 messages May 20, 2020

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

PATCH 1/1 remoteproc: Fix an error code in devm_rproc_alloc()

The comments say that this function should return NULL on error and the caller expects NULL returns as well so I have modified the code to match. Returning an ERR_PTR(-ENOMEM) would lead to an OOps.

Fixes 305ac5a766b1 ("remoteproc: Add device-managed variants of rproc_alloc/rproc_add")
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 0cc015fabf78..9f04c30c4aaf 100644
@@ -2297,7 +2297,7 @@ struct rproc *devm_rproc_alloc(struct device *dev, const char *name,
 
 	ptr = devres_alloc(devm_rproc_free, sizeof(*ptr), GFP_KERNEL);
 	if (!ptr)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	rproc = rproc_alloc(dev, name, ops, firmware, len);
 	if (rproc) {
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,

Quoted 9 lines · Dan Carpenter

The comments say that this function should return NULL on error and the
caller expects NULL returns as well so I have modified the code to match.
Returning an ERR_PTR(-ENOMEM) would lead to an OOps.

Fixes 305ac5a766b1 ("remoteproc: Add device-managed variants of

rproc_alloc/rproc_add")

Alright, makes sense.

Cheers,
-Paul

Quoted 22 lines
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 0cc015fabf78..9f04c30c4aaf 100644
@@ -2297,7 +2297,7 @@ struct rproc *devm_rproc_alloc(struct device 
 *dev, const char *name,
 
 	ptr = devres_alloc(devm_rproc_free, sizeof(*ptr), GFP_KERNEL);
 	if (!ptr)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	rproc = rproc_alloc(dev, name, ops, firmware, len);

if (rproc) {
--
2.26.2

#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

The comments say that this function should return NULL on error and the caller expects NULL returns as well so I have modified the code to match. Returning an ERR_PTR(-ENOMEM) would lead to an OOps.

Fixes 305ac5a766b1 ("remoteproc: Add device-managed variants of rproc_alloc/rproc_add")

Reviewed-by and applied

Thanks,
Bjorn

Quoted 20 lines
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 0cc015fabf78..9f04c30c4aaf 100644
@@ -2297,7 +2297,7 @@ struct rproc *devm_rproc_alloc(struct device *dev, const char *name,
 
 	ptr = devres_alloc(devm_rproc_free, sizeof(*ptr), GFP_KERNEL);
 	if (!ptr)
-		return ERR_PTR(-ENOMEM);
+		return NULL;
 
 	rproc = rproc_alloc(dev, name, ops, firmware, len);
 	if (rproc) {
Signature · 1 line
2.26.2
#3 lore raw
In reply to Dan Carpenter
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 8 lines · On Wed, 20 May 2020 15:07:05 +0300 you wrote:

The comments say that this function should return NULL on error and the caller expects NULL returns as well so I have modified the code to match. Returning an ERR_PTR(-ENOMEM) would lead to an OOps.

Fixes 305ac5a766b1 ("remoteproc: Add device-managed variants of rproc_alloc/rproc_add")

[...]

Here is a summary with links:
- remoteproc: Fix an error code in devm_rproc_alloc()

    https://git.kernel.org/andersson/remoteproc/c/7dcef3988eedbfb40e7e95a821966a029a5a465b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot