* [PATCH] nbd: avoid losing the pointer to reallocated config->socks in nbd_add_socket()
@ 2018-10-06 18:07 Eugene Syromiatnikov
0 siblings, 0 replies; only message in thread
From: Eugene Syromiatnikov @ 2018-10-06 18:07 UTC (permalink / raw)
To: nbd, linux-block; +Cc: linux-kernel, Josef Bacik, Jens Axboe
In the (very unlikely) case of config->socks reallocation success and
nsock allocation failure config->nsock will not get updated with the new pointer
to socks array. Fix it by updating config->socks right after reallocation
successfulness check.
Fixes: 9561a7ade0c2 ("nbd: add multi-connection support")
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
Cc: stable@vger.kernel.org # 4.10+
---
drivers/block/nbd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 14a5125..bfeaf68 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -951,14 +951,14 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
sockfd_put(sock);
return -ENOMEM;
}
+ config->socks = socks;
+
nsock = kzalloc(sizeof(struct nbd_sock), GFP_KERNEL);
if (!nsock) {
sockfd_put(sock);
return -ENOMEM;
}
- config->socks = socks;
-
nsock->fallback_index = -1;
nsock->dead = false;
mutex_init(&nsock->tx_lock);
--
2.1.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-06 18:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-06 18:07 [PATCH] nbd: avoid losing the pointer to reallocated config->socks in nbd_add_socket() Eugene Syromiatnikov
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.