irmap: Duplicate handle memory when queueing for predump

Submitted by Pavel Emelianov on June 29, 2017, 7:35 a.m.

Details

Message ID 154955ac-280a-ab3c-dd54-9f2cf83868db@virtuozzo.com
State Accepted
Series "irmap: Duplicate handle memory when queueing for predump"
Headers show

Commit Message

Pavel Emelianov June 29, 2017, 7:35 a.m.
With the recent cleanups in fdinfo parsing the memory
allocation policy for entries has changed, thus keeping
a pointer on the entry handle is no longer valid (it
will be freed soon).

Said that -- duplicate the memory for queued irmap work.

https://github.com/xemul/criu/issues/328

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
---
 criu/irmap.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/irmap.c b/criu/irmap.c
index c27fdd7..107e0f2 100644
--- a/criu/irmap.c
+++ b/criu/irmap.c
@@ -311,7 +311,12 @@  int irmap_queue_cache(unsigned int dev, unsigned long ino,
 	ip->dev = dev;
 	ip->ino = ino;
 	ip->fh = *fh;
-	fh->handle = NULL; /* don't free in free_fhandle */
+	ip->fh.handle = xmemdup(fh->handle,
+			FH_ENTRY_SIZES__min_entries * sizeof(uint64_t));
+	if (!ip->fh.handle) {
+		xfree(ip);
+		return -1;
+	}
 
 	pr_debug("Queue %x:%lx for pre-dump\n", dev, ino);