diff mbox series

[net] octeontx2-af: debugfs: fix error return of allocations

Message ID 20220430194656.44357-1-dossche.niels@gmail.com (mailing list archive)
State Accepted
Commit 0b9f1b265ee16cd991714fe310eb59b800c142c5
Delegated to: Netdev Maintainers
Headers show
Series [net] octeontx2-af: debugfs: fix error return of allocations | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 3 blamed authors not CCed: bbudiredla@marvell.com bprakash@marvell.com rsaladi2@marvell.com; 3 maintainers not CCed: bbudiredla@marvell.com bprakash@marvell.com rsaladi2@marvell.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Niels Dossche April 30, 2022, 7:46 p.m. UTC
Current memory failure code in the debugfs returns -ENOSPC. This is
normally used for indicating that there is no space left on the
device and is not applicable for memory allocation failures.
Replace this with -ENOMEM.

Fixes: 0daa55d033b0 ("octeontx2-af: cn10k: debugfs for dumping LMTST map table")
Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---

I found this issue using static analysis to find inconsistent error
handling regarding kernel APIs. Found on v5.17.5.
As I do not have the necessary hardware, I only managed to compile test
this on x86_64. I wasn't too sure if it belongs in -net-next or -net,
because while it could theoretically affect users and is a bug in
principle, it probably doesn't do much harm.

 drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski May 2, 2022, 9:31 p.m. UTC | #1
On Sat, 30 Apr 2022 21:46:56 +0200 Niels Dossche wrote:
> @@ -407,7 +407,7 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
>  
>  	buf = kzalloc(buf_size, GFP_KERNEL);
>  	if (!buf)
> -		return -ENOSPC;
> +		return -ENOMEM;
>  
>  	/* Get the maximum width of a column */
>  	lf_str_size = get_max_column_width(rvu);

Looks intentional, other allocation failures in this file use ENOMEM.
Still probably worth cleaning up, applied to net-next.
patchwork-bot+netdevbpf@kernel.org May 2, 2022, 9:40 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 30 Apr 2022 21:46:56 +0200 you wrote:
> Current memory failure code in the debugfs returns -ENOSPC. This is
> normally used for indicating that there is no space left on the
> device and is not applicable for memory allocation failures.
> Replace this with -ENOMEM.
> 
> Fixes: 0daa55d033b0 ("octeontx2-af: cn10k: debugfs for dumping LMTST map table")
> Fixes: 23205e6d06d4 ("octeontx2-af: Dump current resource provisioning status")
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net] octeontx2-af: debugfs: fix error return of allocations
    https://git.kernel.org/netdev/net-next/c/0b9f1b265ee1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index d1eddb769a41..2ad73b180276 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -248,7 +248,7 @@  static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
 	if (!buf)
-		return -ENOSPC;
+		return -ENOMEM;
 
 	tbl_base = rvu_read64(rvu, BLKADDR_APR, APR_AF_LMT_MAP_BASE);
 
@@ -407,7 +407,7 @@  static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
 	if (!buf)
-		return -ENOSPC;
+		return -ENOMEM;
 
 	/* Get the maximum width of a column */
 	lf_str_size = get_max_column_width(rvu);