net/rds/tcp_listen.c:136 rds_tcp_accept_one() error: we previously assumed 'new_sock' could be null (see line 131)

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Gerd Rausch <[email protected]>
CC: Jakub Kicinski <[email protected]>
CC: Jack Vogel <[email protected]>
CC: Allison Henderson <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   818bebeb63dd6bf5f4e07e145f6cdbace520a34c
commit: db69e9b838c39f4fb17d0547aeb71d55a7f28061 net/rds: rds_tcp_accept_one ought to not discard messages
date:   7 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 7 months ago
config: powerpc64-randconfig-r071-20260821 (https://download.01.org/0day-ci/archive/20260821/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 16.1.0
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: db69e9b838c3 ("net/rds: rds_tcp_accept_one ought to not discard messages")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
net/rds/tcp_listen.c:136 rds_tcp_accept_one() error: we previously assumed 'new_sock' could be null (see line 131)

vim +/new_sock +136 net/rds/tcp_listen.c

db69e9b838c39f Gerd Rausch       2026-01-21  107  
db69e9b838c39f Gerd Rausch       2026-01-21  108  int rds_tcp_accept_one(struct rds_tcp_net *rtn)
70041088e3b976 Andy Grover       2009-08-21  109  {
db69e9b838c39f Gerd Rausch       2026-01-21  110  	struct socket *listen_sock = rtn->rds_tcp_listen_sock;
70041088e3b976 Andy Grover       2009-08-21  111  	struct socket *new_sock = NULL;
70041088e3b976 Andy Grover       2009-08-21  112  	struct rds_connection *conn;
70041088e3b976 Andy Grover       2009-08-21  113  	int ret;
70041088e3b976 Andy Grover       2009-08-21  114  	struct inet_sock *inet;
bd7c5f983f3185 Sowmini Varadhan  2016-05-02  115  	struct rds_tcp_connection *rs_tcp = NULL;
bd7c5f983f3185 Sowmini Varadhan  2016-05-02  116  	int conn_state;
ea3b1ea5393087 Sowmini Varadhan  2016-06-30  117  	struct rds_conn_path *cp;
1e2b44e78eead7 Ka-Cheong Poon    2018-07-23  118  	struct in6_addr *my_addr, *peer_addr;
e65d4d96334e3f Ka-Cheong Poon    2018-07-30  119  #if !IS_ENABLED(CONFIG_IPV6)
e65d4d96334e3f Ka-Cheong Poon    2018-07-30  120  	struct in6_addr saddr, daddr;
e65d4d96334e3f Ka-Cheong Poon    2018-07-30  121  #endif
e65d4d96334e3f Ka-Cheong Poon    2018-07-30  122  	int dev_if = 0;
70041088e3b976 Andy Grover       2009-08-21  123  
db69e9b838c39f Gerd Rausch       2026-01-21  124  	if (!listen_sock) /* module unload or netns delete in progress */
37e14f4fe2991f Sowmini Varadhan  2016-05-18  125  		return -ENETUNREACH;
37e14f4fe2991f Sowmini Varadhan  2016-05-18  126  
db69e9b838c39f Gerd Rausch       2026-01-21  127  	mutex_lock(&rtn->rds_tcp_accept_lock);
db69e9b838c39f Gerd Rausch       2026-01-21  128  	new_sock = rtn->rds_tcp_accepted_sock;
db69e9b838c39f Gerd Rausch       2026-01-21  129  	rtn->rds_tcp_accepted_sock = NULL;
db69e9b838c39f Gerd Rausch       2026-01-21  130  
db69e9b838c39f Gerd Rausch       2026-01-21 @131  	if (!new_sock) {
db69e9b838c39f Gerd Rausch       2026-01-21  132  		ret = kernel_accept(listen_sock, &new_sock, O_NONBLOCK);
70041088e3b976 Andy Grover       2009-08-21  133  		if (ret)
db69e9b838c39f Gerd Rausch       2026-01-21  134  			goto out;
84eef2b2187ed7 Ka-Cheong Poon    2018-03-01  135  
480aeb9639d6a0 Christoph Hellwig 2020-05-28 @136  		rds_tcp_keepalive(new_sock);
6997fbd7a3dafa Tetsuo Handa      2022-05-05  137  		if (!rds_tcp_tune(new_sock)) {
6997fbd7a3dafa Tetsuo Handa      2022-05-05  138  			ret = -EINVAL;
6997fbd7a3dafa Tetsuo Handa      2022-05-05  139  			goto out;
6997fbd7a3dafa Tetsuo Handa      2022-05-05  140  		}
db69e9b838c39f Gerd Rausch       2026-01-21  141  	}
70041088e3b976 Andy Grover       2009-08-21  142  
70041088e3b976 Andy Grover       2009-08-21  143  	inet = inet_sk(new_sock->sk);
70041088e3b976 Andy Grover       2009-08-21  144  

:::::: The code at line 136 was first introduced by commit
:::::: 480aeb9639d6a077c611b303a22f9b1e5937d081 tcp: add tcp_sock_set_keepcnt

:::::: TO: Christoph Hellwig <[email protected]>
:::::: CC: David S. Miller <[email protected]>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.