mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
gtp: fix a potential NULL pointer dereference
[ Upstream commitdefd8b3c37
] 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:1e3a3abd8b
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6b59806916
commit
28c67f0f84
|
@ -1220,7 +1220,7 @@ static struct sock *gtp_encap_enable_socket(int fd, int type,
|
||||||
sock = sockfd_lookup(fd, &err);
|
sock = sockfd_lookup(fd, &err);
|
||||||
if (!sock) {
|
if (!sock) {
|
||||||
pr_debug("gtp socket fd=%d not found\n", fd);
|
pr_debug("gtp socket fd=%d not found\n", fd);
|
||||||
return NULL;
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk = sock->sk;
|
sk = sock->sk;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user