Skip to contentSkip to conversation

ksmbd: add missing assignments to ret on ndr_read_int64 read calls

PATCH In review Colin King 3 participants 3 messages Sep 6, 2021 – Sep 7, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 ksmbd: add missing assignments to ret on ndr_read_int64 read calls

From: Colin Ian King <[email protected]>

Currently there are two ndr_read_int64 calls where ret is being checked for failure but ret is not being assigned a return value from the call. Static analyis is reporting the checks on ret as dead code. Fix this.

Addresses-Coverity: ("Logical dead code")

Fixes 303fff2b8c77 ("ksmbd: add validation for ndr read/write functions")
---
 fs/ksmbd/ndr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ksmbd/ndr.c +2 -2
index a476de291f62..8317f7ca402b 100644
@@ -275,11 +275,11 @@ int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da)
 		if (ret)
 			return ret;
 
-		ndr_read_int64(n, NULL);
+		ret = ndr_read_int64(n, NULL);
 		if (ret)
 			return ret;
 
-		ndr_read_int64(n, NULL);
+		ret = ndr_read_int64(n, NULL);
 		if (ret)
 			return ret;
 
Signature · 1 line
2.32.0
maintainer
#1 lore raw

2021-09-06 22:44 GMT+09:00, Colin King <[email protected]>:

Quoted 9 lines

From: Colin Ian King <[email protected]>

Currently there are two ndr_read_int64 calls where ret is being checked for failure but ret is not being assigned a return value from the call. Static analyis is reporting the checks on ret as dead code. Fix this.

Addresses-Coverity: ("Logical dead code")

Fixes 303fff2b8c77 ("ksmbd: add validation for ndr read/write functions")

Applied it to my queue. I will send it to Steve after testing. Thanks for your patch!

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Colin King

On (21/09/06 14:44), Colin King wrote:
[..]

fs/ksmbd/ndr.c int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da) · line 284

Quoted 13 lines
fs/ksmbd/ndr.c +2 -2
@@ -275,11 +275,11 @@ int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da)
 		if (ret)
 			return ret;
 
-		ndr_read_int64(n, NULL);
+		ret = ndr_read_int64(n, NULL);
 		if (ret)
 			return ret;
 
-		ndr_read_int64(n, NULL);
+		ret = ndr_read_int64(n, NULL);
 		if (ret)
 			return ret;

A pretty nice catch by that static analyzer tool.