Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1281,23 +1281,17 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
struct socket *sock;
struct nbd_sock **socks;
struct nbd_sock *nsock;
unsigned int memflags;
int err;

/* Arg will be cast to int, check it to avoid overflow */
if (arg > INT_MAX)
return -EINVAL;

sock = nbd_get_socket(nbd, arg, &err);
if (!sock)
return err;
nbd_reclassify_socket(sock);

/*
* We need to make sure we don't get any errant requests while we're
* reallocating the ->socks array.
*/
memflags = blk_mq_freeze_queue(nbd->disk->queue);

if (!netlink && !nbd->task_setup &&
!test_bit(NBD_RT_BOUND, &config->runtime_flags))
nbd->task_setup = current;
Expand Down Expand Up @@ -1337,12 +1331,9 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
INIT_WORK(&nsock->work, nbd_pending_cmd_work);
socks[config->num_connections++] = nsock;
atomic_inc(&config->live_connections);
blk_mq_unfreeze_queue(nbd->disk->queue, memflags);

return 0;

put_socket:
blk_mq_unfreeze_queue(nbd->disk->queue, memflags);
sockfd_put(sock);
return err;
}
Expand Down
Loading