Skip to contentSkip to conversation

fwctl/pds: propagate actual error code instead of hardcoded -ENOMEM

PATCH In review Jackie Liu 3 participants 3 messages Jun 3

Subsystems (2)
lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH 1/1 fwctl/pds: propagate actual error code instead of hardcoded -ENOMEM

From: Jackie Liu <[email protected]>

When pdsfc_get_operations() fails in pdsfc_validate_rpc(), the function hardcodes the return value to -ENOMEM regardless of the actual failure. pdsfc_get_operations() can return various errors from the adminq command (e.g. -ETIMEDOUT, -EIO, -ENODEV) or from DMA mapping failure (-ENOMEM). Propagate the actual error via PTR_ERR(operations) so userspace and debugging tools see the correct failure reason.

Fixes 92c66ee829b9 ("pds_fwctl: add rpc and query support")
---
 drivers/fwctl/pds/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fwctl/pds/main.c +1 -1
index 68fe254dd10a..a4e80cfa3c50 100644
@@ -325,7 +325,7 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
 						  rpc->in.ep);
 		if (IS_ERR(operations)) {
 			mutex_unlock(&ep_info->lock);
-			return -ENOMEM;
+			return PTR_ERR(operations);
 		}
 		ep_info->operations = operations;
 	}
Signature · 1 line
2.54.0
Reviewed-by Brett Creeley on v1 1/1
#1 lore raw
Quoted 26 lines · Jackie Liu

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

From: Jackie Liu <[email protected]>

When pdsfc_get_operations() fails in pdsfc_validate_rpc(), the function hardcodes the return value to -ENOMEM regardless of the actual failure. pdsfc_get_operations() can return various errors from the adminq command (e.g. -ETIMEDOUT, -EIO, -ENODEV) or from DMA mapping failure (-ENOMEM). Propagate the actual error via PTR_ERR(operations) so userspace and debugging tools see the correct failure reason.

Fixes 92c66ee829b9 ("pds_fwctl: add rpc and query support")
---
  drivers/fwctl/pds/main.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fwctl/pds/main.c +0 -0
index 68fe254dd10a..a4e80cfa3c50 100644

drivers/fwctl/pds/main.c static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc, · line 328

Quoted 5 lines
drivers/fwctl/pds/main.c +1 -1
@@ -325,7 +325,7 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
                                                   rpc->in.ep);
                 if (IS_ERR(operations)) {
                         mutex_unlock(&ep_info->lock);
-                       return -ENOMEM;
+                       return PTR_ERR(operations);

LGTM. Thanks for the fix.

Quoted 6 lines
drivers/fwctl/pds/main.c +0 -1
                 }
                 ep_info->operations = operations;
         }
--

2.54.0

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Jackie Liu
Quoted 10 lines · Jackie Liu

From: Jackie Liu <[email protected]>

When pdsfc_get_operations() fails in pdsfc_validate_rpc(), the function hardcodes the return value to -ENOMEM regardless of the actual failure. pdsfc_get_operations() can return various errors from the adminq command (e.g. -ETIMEDOUT, -EIO, -ENODEV) or from DMA mapping failure (-ENOMEM). Propagate the actual error via PTR_ERR(operations) so userspace and debugging tools see the correct failure reason.

Quoted 2 lines
Fixes 92c66ee829b9 ("pds_fwctl: add rpc and query support")
Quoted 17 lines
---
 drivers/fwctl/pds/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fwctl/pds/main.c +1 -1
index 68fe254dd10a..a4e80cfa3c50 100644
@@ -325,7 +325,7 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
 						  rpc->in.ep);
 		if (IS_ERR(operations)) {
 			mutex_unlock(&ep_info->lock);
-			return -ENOMEM;
+			return PTR_ERR(operations);
 		}
 		ep_info->operations = operations;
 	}