All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [bytedance:6.6-velinux 5959/5959] drivers/block/nbd.c:1298 nbd_reconnect_socket() warn: inconsistent returns '&nsock->tx_lock'.
Date: Fri, 19 Sep 2025 18:40:50 +0800	[thread overview]
Message-ID: <202509191844.UIjeXrdY-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: jason.zeng@intel.com

tree:   https://github.com/bytedance/kernel.git 6.6-velinux
head:   267e33ff5e034d9f9222c229e6967b6ceb65e27a
commit: 454e732aaf9bdba6d2183f14939163e6a37dfbd3 [5959/5959] bytedance: nbd: Don't use workqueue to create recv threads
:::::: branch date: 26 hours ago
:::::: commit date: 26 hours ago
config: x86_64-randconfig-161-20250919 (https://download.01.org/0day-ci/archive/20250919/202509191844.UIjeXrdY-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

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
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202509191844.UIjeXrdY-lkp@intel.com/

smatch warnings:
drivers/block/nbd.c:1298 nbd_reconnect_socket() warn: inconsistent returns '&nsock->tx_lock'.

vim +1298 drivers/block/nbd.c

23272a6754b81f Markus Schneider-Pargmann 2015-10-29  1229  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1230  static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1231  {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1232  	struct nbd_config *config = nbd->config;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1233  	struct socket *sock, *old;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1234  	struct recv_thread_args *args;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1235  	int i;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1236  	int err;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1237  
cf1b2326b73489 Mike Christie             2019-10-17  1238  	sock = nbd_get_socket(nbd, arg, &err);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1239  	if (!sock)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1240  		return err;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1241  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1242  	args = kzalloc(sizeof(*args), GFP_KERNEL);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1243  	if (!args) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1244  		sockfd_put(sock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1245  		return -ENOMEM;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1246  	}
b7aa3d39385dc2 Josef Bacik               2017-04-06  1247  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1248  	for (i = 0; i < config->num_connections; i++) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1249  		struct nbd_sock *nsock = config->socks[i];
454e732aaf9bdb Xie Yongji                2021-12-17  1250  		struct task_struct *worker;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1251  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1252  		if (!nsock->dead)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1253  			continue;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1254  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1255  		mutex_lock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1256  		if (!nsock->dead) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1257  			mutex_unlock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1258  			continue;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1259  		}
454e732aaf9bdb Xie Yongji                2021-12-17  1260  		worker = kthread_create(recv_work, args, "knbd%d.%d-recv",
454e732aaf9bdb Xie Yongji                2021-12-17  1261  					nbd->index, i);
454e732aaf9bdb Xie Yongji                2021-12-17  1262  		if (!worker) {
454e732aaf9bdb Xie Yongji                2021-12-17  1263  			sockfd_put(sock);
454e732aaf9bdb Xie Yongji                2021-12-17  1264  			kfree(args);
454e732aaf9bdb Xie Yongji                2021-12-17  1265  			return -ENOMEM;
454e732aaf9bdb Xie Yongji                2021-12-17  1266  		}
454e732aaf9bdb Xie Yongji                2021-12-17  1267  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1268  		sk_set_memalloc(sock->sk);
5eafd64a3bd2ab Hou Pu                    2020-11-06  1269  		if (nbd->tag_set.timeout &&
5eafd64a3bd2ab Hou Pu                    2020-11-06  1270  		    !test_bit(NBD_RT_WAIT_ON_TIMEOUT, &config->runtime_flags))
dc88e34d69d87c Josef Bacik               2017-06-08  1271  			sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1272  		atomic_inc(&config->recv_threads);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1273  		refcount_inc(&nbd->config_refs);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1274  		old = nsock->sock;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1275  		nsock->fallback_index = -1;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1276  		nsock->sock = sock;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1277  		nsock->dead = false;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1278  		args->index = i;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1279  		args->nbd = nbd;
7e62a555d99f2f Li Nan                    2023-09-11  1280  		args->nsock = nsock;
799f9a38bc9f55 Josef Bacik               2017-04-06  1281  		nsock->cookie++;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1282  		mutex_unlock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1283  		sockfd_put(old);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1284  
ec76a7b922e42d Xiubo Li                  2019-09-17  1285  		clear_bit(NBD_RT_DISCONNECTED, &config->runtime_flags);
7a362ea96d0df8 Josef Bacik               2017-07-25  1286  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1287  		/* We take the tx_mutex in an error path in the recv_work, so we
b7aa3d39385dc2 Josef Bacik               2017-04-06  1288  		 * need to queue_work outside of the tx_mutex.
b7aa3d39385dc2 Josef Bacik               2017-04-06  1289  		 */
454e732aaf9bdb Xie Yongji                2021-12-17  1290  		wake_up_process(worker);
560bc4b39952ed Josef Bacik               2017-04-06  1291  
560bc4b39952ed Josef Bacik               2017-04-06  1292  		atomic_inc(&config->live_connections);
560bc4b39952ed Josef Bacik               2017-04-06  1293  		wake_up(&config->conn_wait);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1294  		return 0;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1295  	}
b7aa3d39385dc2 Josef Bacik               2017-04-06  1296  	sockfd_put(sock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1297  	kfree(args);
b7aa3d39385dc2 Josef Bacik               2017-04-06 @1298  	return -ENOSPC;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1299  }
b7aa3d39385dc2 Josef Bacik               2017-04-06  1300  

:::::: The code at line 1298 was first introduced by commit
:::::: b7aa3d39385dc2d95899f9e379623fef446a2acd nbd: add a reconfigure netlink command

:::::: TO: Josef Bacik <josef@toxicpanda.com>
:::::: CC: Jens Axboe <axboe@fb.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, jason.zeng@intel.com
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev
Subject: [bytedance:6.6-velinux 5959/5959] drivers/block/nbd.c:1298 nbd_reconnect_socket() warn: inconsistent returns '&nsock->tx_lock'.
Date: Fri, 19 Sep 2025 14:19:26 +0300	[thread overview]
Message-ID: <202509191844.UIjeXrdY-lkp@intel.com> (raw)
Message-ID: <20250919111926.DX85DQKaGA6eb3HLhLLAvP-dPZ14lf1-qELzX0AbVLU@z> (raw)

tree:   https://github.com/bytedance/kernel.git 6.6-velinux
head:   267e33ff5e034d9f9222c229e6967b6ceb65e27a
commit: 454e732aaf9bdba6d2183f14939163e6a37dfbd3 [5959/5959] bytedance: nbd: Don't use workqueue to create recv threads
config: x86_64-randconfig-161-20250919 (https://download.01.org/0day-ci/archive/20250919/202509191844.UIjeXrdY-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

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
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202509191844.UIjeXrdY-lkp@intel.com/

smatch warnings:
drivers/block/nbd.c:1298 nbd_reconnect_socket() warn: inconsistent returns '&nsock->tx_lock'.

vim +1298 drivers/block/nbd.c

b7aa3d39385dc2 Josef Bacik               2017-04-06  1230  static int nbd_reconnect_socket(struct nbd_device *nbd, unsigned long arg)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1231  {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1232  	struct nbd_config *config = nbd->config;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1233  	struct socket *sock, *old;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1234  	struct recv_thread_args *args;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1235  	int i;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1236  	int err;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1237  
cf1b2326b73489 Mike Christie             2019-10-17  1238  	sock = nbd_get_socket(nbd, arg, &err);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1239  	if (!sock)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1240  		return err;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1241  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1242  	args = kzalloc(sizeof(*args), GFP_KERNEL);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1243  	if (!args) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1244  		sockfd_put(sock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1245  		return -ENOMEM;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1246  	}
b7aa3d39385dc2 Josef Bacik               2017-04-06  1247  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1248  	for (i = 0; i < config->num_connections; i++) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1249  		struct nbd_sock *nsock = config->socks[i];
454e732aaf9bdb Xie Yongji                2021-12-17  1250  		struct task_struct *worker;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1251  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1252  		if (!nsock->dead)
b7aa3d39385dc2 Josef Bacik               2017-04-06  1253  			continue;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1254  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1255  		mutex_lock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1256  		if (!nsock->dead) {
b7aa3d39385dc2 Josef Bacik               2017-04-06  1257  			mutex_unlock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1258  			continue;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1259  		}
454e732aaf9bdb Xie Yongji                2021-12-17  1260  		worker = kthread_create(recv_work, args, "knbd%d.%d-recv",
454e732aaf9bdb Xie Yongji                2021-12-17  1261  					nbd->index, i);
454e732aaf9bdb Xie Yongji                2021-12-17  1262  		if (!worker) {
454e732aaf9bdb Xie Yongji                2021-12-17  1263  			sockfd_put(sock);
454e732aaf9bdb Xie Yongji                2021-12-17  1264  			kfree(args);
454e732aaf9bdb Xie Yongji                2021-12-17  1265  			return -ENOMEM;

Call mutex_unlock(&nsock->tx_lock); before returning.

454e732aaf9bdb Xie Yongji                2021-12-17  1266  		}
454e732aaf9bdb Xie Yongji                2021-12-17  1267  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1268  		sk_set_memalloc(sock->sk);
5eafd64a3bd2ab Hou Pu                    2020-11-06  1269  		if (nbd->tag_set.timeout &&
5eafd64a3bd2ab Hou Pu                    2020-11-06  1270  		    !test_bit(NBD_RT_WAIT_ON_TIMEOUT, &config->runtime_flags))
dc88e34d69d87c Josef Bacik               2017-06-08  1271  			sock->sk->sk_sndtimeo = nbd->tag_set.timeout;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1272  		atomic_inc(&config->recv_threads);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1273  		refcount_inc(&nbd->config_refs);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1274  		old = nsock->sock;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1275  		nsock->fallback_index = -1;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1276  		nsock->sock = sock;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1277  		nsock->dead = false;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1278  		args->index = i;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1279  		args->nbd = nbd;
7e62a555d99f2f Li Nan                    2023-09-11  1280  		args->nsock = nsock;
799f9a38bc9f55 Josef Bacik               2017-04-06  1281  		nsock->cookie++;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1282  		mutex_unlock(&nsock->tx_lock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1283  		sockfd_put(old);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1284  
ec76a7b922e42d Xiubo Li                  2019-09-17  1285  		clear_bit(NBD_RT_DISCONNECTED, &config->runtime_flags);
7a362ea96d0df8 Josef Bacik               2017-07-25  1286  
b7aa3d39385dc2 Josef Bacik               2017-04-06  1287  		/* We take the tx_mutex in an error path in the recv_work, so we
b7aa3d39385dc2 Josef Bacik               2017-04-06  1288  		 * need to queue_work outside of the tx_mutex.
b7aa3d39385dc2 Josef Bacik               2017-04-06  1289  		 */
454e732aaf9bdb Xie Yongji                2021-12-17  1290  		wake_up_process(worker);
560bc4b39952ed Josef Bacik               2017-04-06  1291  
560bc4b39952ed Josef Bacik               2017-04-06  1292  		atomic_inc(&config->live_connections);
560bc4b39952ed Josef Bacik               2017-04-06  1293  		wake_up(&config->conn_wait);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1294  		return 0;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1295  	}
b7aa3d39385dc2 Josef Bacik               2017-04-06  1296  	sockfd_put(sock);
b7aa3d39385dc2 Josef Bacik               2017-04-06  1297  	kfree(args);
b7aa3d39385dc2 Josef Bacik               2017-04-06 @1298  	return -ENOSPC;
b7aa3d39385dc2 Josef Bacik               2017-04-06  1299  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


             reply	other threads:[~2025-09-19 10:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 10:40 kernel test robot [this message]
2025-09-19 11:19 ` [bytedance:6.6-velinux 5959/5959] drivers/block/nbd.c:1298 nbd_reconnect_socket() warn: inconsistent returns '&nsock->tx_lock' Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202509191844.UIjeXrdY-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.