提交 9b1355d5 编写于 作者: J Josef Bacik 提交者: Jens Axboe

nbd: put socket in error cases

When adding a new socket we look it up and then try to add it to our
configuration.  If any of those steps fail we need to make sure we put
the socket so we don't leak them.
Signed-off-by: NJosef Bacik <jbacik@fb.com>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 1c6286f2
......@@ -628,16 +628,21 @@ static int nbd_add_socket(struct nbd_device *nbd, struct block_device *bdev,
if (nbd->task_setup != current) {
dev_err(disk_to_dev(nbd->disk),
"Device being setup by another task");
sockfd_put(sock);
return -EINVAL;
}
socks = krealloc(nbd->socks, (nbd->num_connections + 1) *
sizeof(struct nbd_sock *), GFP_KERNEL);
if (!socks)
if (!socks) {
sockfd_put(sock);
return -ENOMEM;
}
nsock = kzalloc(sizeof(struct nbd_sock), GFP_KERNEL);
if (!nsock)
if (!nsock) {
sockfd_put(sock);
return -ENOMEM;
}
nbd->socks = socks;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册