mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
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.
Fixes: 72904d7b9b ("rxrpc, afs: Allow afs to pin rxrpc_peer objects")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Co-developed-by: David Howells <dhowells@redhat.com>
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
Link: https://patch.msgid.link/368272.1772713861@warthog.procyon.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
7a4d74676c
commit
4245a79003
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user