Skip to content

Commit d25e44f

Browse files
committed
rxrpc: Fix checker warning
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-284.30.1.el9_2 commit-author David Howells <[email protected]> commit 84924aa Fix the following checker warning: ../net/rxrpc/key.c:692:9: error: subtraction of different types can't work (different address spaces) Checker is wrong in this case, but cast the pointers to unsigned long to avoid the warning. Whilst we're at it, reduce the assertions to WARN_ON() and return an error. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected] (cherry picked from commit 84924aa) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 6365de1 commit d25e44f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/rxrpc/key.c

+9-5
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ static long rxrpc_read(const struct key *key,
602602
}
603603

604604
_debug("token[%u]: toksize=%u", ntoks, toksize);
605-
ASSERTCMP(toksize, <=, AFSTOKEN_LENGTH_MAX);
605+
if (WARN_ON(toksize > AFSTOKEN_LENGTH_MAX))
606+
return -EIO;
606607

607608
toksizes[ntoks++] = toksize;
608609
size += toksize + 4; /* each token has a length word */
@@ -679,17 +680,20 @@ static long rxrpc_read(const struct key *key,
679680
return -ENOPKG;
680681
}
681682

682-
ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==,
683-
toksize);
683+
if (WARN_ON((unsigned long)xdr - (unsigned long)oldxdr ==
684+
toksize))
685+
return -EIO;
684686
}
685687

686688
#undef ENCODE_STR
687689
#undef ENCODE_DATA
688690
#undef ENCODE64
689691
#undef ENCODE
690692

691-
ASSERTCMP(tok, ==, ntoks);
692-
ASSERTCMP((char __user *) xdr - buffer, ==, size);
693+
if (WARN_ON(tok != ntoks))
694+
return -EIO;
695+
if (WARN_ON((unsigned long)xdr - (unsigned long)buffer != size))
696+
return -EIO;
693697
_leave(" = %zu", size);
694698
return size;
695699
}

0 commit comments

Comments
 (0)