summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2023-05-11 17:47:40 +0200
committerJakub Kicinski <kuba@kernel.org>2023-05-25 07:05:24 +0200
commit7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4 (patch)
tree8500bd7ee3b1118e41d467cec9bf423c3d6b262b
parentnet/handshake: Remove unneeded check from handshake_dup() (diff)
downloadlinux-7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4.tar.xz
linux-7ea9c1ec66bc099b0bfba961a8a46dfe25d7d8e4.zip
net/handshake: Fix handshake_dup() ref counting
If get_unused_fd_flags() fails, we ended up calling fput(sock->file) twice. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Suggested-by: Paolo Abeni <pabeni@redhat.com> Fixes: 3b3009ea8abb ("net/handshake: Create a NETLINK service for handling handshake requests") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/handshake/netlink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/handshake/netlink.c b/net/handshake/netlink.c
index 7ec8a76c3c8a..f5dc170689d9 100644
--- a/net/handshake/netlink.c
+++ b/net/handshake/netlink.c
@@ -139,15 +139,16 @@ int handshake_nl_accept_doit(struct sk_buff *skb, struct genl_info *info)
goto out_complete;
}
err = req->hr_proto->hp_accept(req, info, fd);
- if (err)
+ if (err) {
+ fput(sock->file);
goto out_complete;
+ }
trace_handshake_cmd_accept(net, req, req->hr_sk, fd);
return 0;
out_complete:
handshake_complete(req, -EIO, NULL);
- fput(sock->file);
out_status:
trace_handshake_cmd_accept_err(net, req, NULL, err);
return err;