Module Name: src
Committed By: agc
Date: Mon Aug 18 17:16:19 UTC 2014
Modified Files:
src/sys/dev/dm: dm_target_snapshot.c
Log Message:
Avoid a memory leak - from maxv
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/dm/dm_target_snapshot.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/dm/dm_target_snapshot.c
diff -u src/sys/dev/dm/dm_target_snapshot.c:1.16 src/sys/dev/dm/dm_target_snapshot.c:1.17
--- src/sys/dev/dm/dm_target_snapshot.c:1.16 Sat Jun 14 07:39:00 2014
+++ src/sys/dev/dm/dm_target_snapshot.c Mon Aug 18 17:16:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_target_snapshot.c,v 1.16 2014/06/14 07:39:00 hannken Exp $ */
+/* $NetBSD: dm_target_snapshot.c,v 1.17 2014/08/18 17:16:19 agc Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -221,8 +221,7 @@ dm_target_snapshot_init(dm_dev_t * dmv,
if ((dmp_snap = dm_pdev_insert(argv[0])) == NULL)
return ENOENT;
- if ((tsc = kmem_alloc(sizeof(dm_target_snapshot_config_t), KM_NOSLEEP))
- == NULL)
+ if ((tsc = kmem_alloc(sizeof(*tsc), KM_NOSLEEP)) == NULL)
return 1;
tsc->tsc_persistent_dev = 0;
@@ -232,8 +231,10 @@ dm_target_snapshot_init(dm_dev_t * dmv,
tsc->tsc_persistent_dev = 1;
/* Insert cow device to global pdev list */
- if ((dmp_cow = dm_pdev_insert(argv[1])) == NULL)
+ if ((dmp_cow = dm_pdev_insert(argv[1])) == NULL) {
+ kmem_free(tsc, sizeof(*tsc));
return ENOENT;
+ }
}
tsc->tsc_chunk_size = atoi(argv[3]);