Skip to content

Commit

Permalink
rxrpc: Fix checker warning
Browse files Browse the repository at this point in the history
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 <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
  • Loading branch information
David Howells committed Dec 1, 2022
1 parent 91a7de8 commit 84924aa
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions net/rxrpc/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ static long rxrpc_read(const struct key *key,
}

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

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

ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==,
toksize);
if (WARN_ON((unsigned long)xdr - (unsigned long)oldxdr ==
toksize))
return -EIO;
}

#undef ENCODE_STR
#undef ENCODE_DATA
#undef ENCODE64
#undef ENCODE

ASSERTCMP(tok, ==, ntoks);
ASSERTCMP((char __user *) xdr - buffer, ==, size);
if (WARN_ON(tok != ntoks))
return -EIO;
if (WARN_ON((unsigned long)xdr - (unsigned long)buffer != size))
return -EIO;
_leave(" = %zu", size);
return size;
}

0 comments on commit 84924aa

Please sign in to comment.