rxrpc, afs: Fix missing error pointer check after rxrpc_kernel_lookup_peer()
Subsystems (4)
David Howells
maintainerPATCH 1/1 rxrpc, afs: Fix missing error pointer check after rxrpc_kernel_lookup_peer()
rxrpc_kernel_lookup_peer() can also return error pointers in addition to NULL, so just checking for NULL is not sufficient.
Fix this by:
(1) Changing rxrpc_kernel_lookup_peer() to return -ENOMEM rather than NULL on allocation failure.
(2) Making the callers in afs use IS_ERR() and PTR_ERR() to pass on the error code returned.
--- fs/afs/addr_list.c | 8 ++++---- net/rxrpc/af_rxrpc.c | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-)
fs/afs/addr_list.c +4 -4
@@ -298,8 +298,8 @@ int afs_merge_fs_addr4(struct afs_net *net, struct afs_addr_list *alist, srx.transport.sin.sin_addr.s_addr = xdr; peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); -if (!peer) -return -ENOMEM ; +if (IS_ERR (peer)) +return PTR_ERR (peer);for (i =0 ; i < alist->nr_ipv4; i++) {if (peer == alist->addrs[i].peer) {
@@ -342,8 +342,8 @@ int afs_merge_fs_addr6(struct afs_net *net, struct afs_addr_list *alist,memcpy (&srx.transport.sin6.sin6_addr, xdr,16 ); peer =rxrpc_kernel_lookup_peer (net->socket, &srx,GFP_KERNEL ); -if (!peer) -return -ENOMEM ; +if (IS_ERR (peer)) +return PTR_ERR (peer);for (i = alist->nr_ipv4; i < alist->nr_addrs; i++) {if (peer == alist->addrs[i].peer) {
net/rxrpc/af_rxrpc.c +5 -3
@@ -267,12 +267,13 @@ static int rxrpc_listen(struct socket *sock, int backlog)* Lookup or create a remote transport endpoint record for the specified * address. * -* Return: The peer record found with a reference, %NULL if no record is found -* or a negative error code if the address is invalid or unsupported. +* Return: The peer record found with a reference or a negative error code if +* the address is invalid or unsupported. */ struct rxrpc_peer *rxrpc_kernel_lookup_peer (struct socket *sock,struct sockaddr_rxrpc *srx,gfp_t gfp) { +struct rxrpc_peer *peer;struct rxrpc_sock *rx =rxrpc_sk (sock->sk);int ret;
@@ -280,7 +281,8 @@ struct rxrpc_peer *rxrpc_kernel_lookup_peer(struct socket *sock,if (ret <0 )return ERR_PTR (ret); -return rxrpc_lookup_peer (rx->local, srx, gfp); + peer =rxrpc_lookup_peer (rx->local, srx, gfp); +return peer ?:ERR_PTR (-ENOMEM ); }EXPORT_SYMBOL (rxrpc_kernel_lookup_peer);
David Howells
maintainerThis patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 05 Mar 2026 12:31:01 +0000 you wrote:
rxrpc_kernel_lookup_peer()can also return error pointers in addition to NULL, so just checking for NULL is not sufficient.Fix this by:
(1) Changing
rxrpc_kernel_lookup_peer()to return-ENOMEMrather than NULL on allocation failure.[...]
Here is the summary with links:
- [net] rxrpc, afs: Fix missing error pointer check after rxrpc_kernel_lookup_peer()
https://git.kernel.org/netdev/net/c/4245a79003ad
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html