When converting from a single transaction to a linked list, I
forgot to free the storage for each member of the list.
Reported-by: Richard W.M. Jones <rjones(a)redhat.com>
Fixes: 7f5bb9bf13f041ea7702bda557d9dd668bc3423a
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
plugins/nbd/nbd.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index b844bf5..e79042c 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -311,6 +311,8 @@ nbd_reply_raw (struct handle *h, int *fd)
struct reply rep;
struct transaction **ptr;
struct transaction *trans;
+ void *buf;
+ uint32_t count;
*fd = -1;
if (read_full (h->fd, &rep, sizeof rep) < 0)
@@ -334,9 +336,12 @@ nbd_reply_raw (struct handle *h, int *fd)
}
*fd = trans->u.fds[1];
+ buf = trans->buf;
+ count = trans->count;
+ free (trans);
switch (be32toh (rep.error)) {
case NBD_SUCCESS:
- if (trans->buf && read_full (h->fd, trans->buf, trans->count)
< 0)
+ if (buf && read_full (h->fd, buf, count) < 0)
return nbd_mark_dead (h);
return 0;
case NBD_EPERM:
@@ -399,6 +404,7 @@ nbd_reader (void *handle)
abort ();
}
close (trans->u.fds[1]);
+ free (trans);
}
return NULL;
}
--
2.14.3