Skip to contentSkip to conversation

UNRPC: Return specific error code on kmalloc failure

PATCH In review Yang Li 2 participants 2 messages Sep 10, 2021 – Sep 23, 2021

Subsystems (4)
lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 UNRPC: Return specific error code on kmalloc failure

Although the callers of this function only care about whether the return value is null or not, we should still give a rigorous error code.

Smatch tool warning:
net/sunrpc/auth_gss/svcauth_gss.c:784 gss_write_verf() warn: returning -1 instead of -ENOMEM is sloppy

No functional change, just more standardized.

---
 net/sunrpc/auth_gss/svcauth_gss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
index 3e776e3..7dba6a9 100644
@@ -781,7 +781,7 @@ static inline u32 round_up_to_quad(u32 i)
 	svc_putnl(rqstp->rq_res.head, RPC_AUTH_GSS);
 	xdr_seq = kmalloc(4, GFP_KERNEL);
 	if (!xdr_seq)
-		return -1;
+		return -ENOMEM;
 	*xdr_seq = htonl(seq);
 
 	iov.iov_base = xdr_seq;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Yang Li

Although the callers of this function only care about whether the return value is null or not, we should still give a rigorous error code.

Eh, I'm not sure I understand why this is important but, OK, applying.--b.

Quoted 28 lines

Smatch tool warning:
net/sunrpc/auth_gss/svcauth_gss.c:784 gss_write_verf() warn: returning -1 instead of -ENOMEM is sloppy

No functional change, just more standardized.

---
 net/sunrpc/auth_gss/svcauth_gss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
index 3e776e3..7dba6a9 100644
@@ -781,7 +781,7 @@ static inline u32 round_up_to_quad(u32 i)
 	svc_putnl(rqstp->rq_res.head, RPC_AUTH_GSS);
 	xdr_seq = kmalloc(4, GFP_KERNEL);
 	if (!xdr_seq)
-		return -1;
+		return -ENOMEM;
 	*xdr_seq = htonl(seq);
 
 	iov.iov_base = xdr_seq;
Signature · 1 line
1.8.3.1