diff options
author | Cong Wang <cong.wang@bytedance.com> | 2024-08-25 22:16:38 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-08-28 00:19:40 +0300 |
commit | defd8b3c37b0f9cb3e0f60f47d3d78d459d57fda (patch) | |
tree | e2d53b01dfcd17753a79378e455105201f924803 /drivers/net/gtp.c | |
parent | 2fecbf75c40aca51ae35accbaa6ea051bb2340c4 (diff) | |
download | linux-defd8b3c37b0f9cb3e0f60f47d3d78d459d57fda.tar.xz |
gtp: fix a potential NULL pointer dereference
When sockfd_lookup() fails, gtp_encap_enable_socket() returns a
NULL pointer, but its callers only check for error pointers thus miss
the NULL pointer case.
Fix it by returning an error pointer with the error code carried from
sockfd_lookup().
(I found this bug during code inspection.)
Fixes: 1e3a3abd8b28 ("gtp: make GTP sockets in gtp_newlink optional")
Cc: Andreas Schultz <aschultz@tpip.net>
Cc: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
Link: https://patch.msgid.link/20240825191638.146748-1-xiyou.wangcong@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/gtp.c')
-rw-r--r-- | drivers/net/gtp.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 0696faf60013..2e94d10348cc 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -1653,7 +1653,7 @@ static struct sock *gtp_encap_enable_socket(int fd, int type, sock = sockfd_lookup(fd, &err); if (!sock) { pr_debug("gtp socket fd=%d not found\n", fd); - return NULL; + return ERR_PTR(err); } sk = sock->sk; |