summaryrefslogtreecommitdiff
path: root/sys/dev/dm/dm_pdev.c
diff options
context:
space:
mode:
authortkusumi <tkusumi@NetBSD.org>2019-12-13 15:49:22 +0000
committertkusumi <tkusumi@NetBSD.org>2019-12-13 15:49:22 +0000
commit7f8e50674f068e66d52f9ca5e301ece8bcaa1afe (patch)
treebbf6aba340a4f238344af4ca9b31d55a13c9ca59 /sys/dev/dm/dm_pdev.c
parent590463e90614a30c826c96eb05f7b731ba698787 (diff)
dm: Fix memory leak in dm_pdev_rem()
Need to free dmp regardless of dm_pdev_rem() return value. taken-from: DragonFlyBSD
Diffstat (limited to 'sys/dev/dm/dm_pdev.c')
-rw-r--r--sys/dev/dm/dm_pdev.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/dev/dm/dm_pdev.c b/sys/dev/dm/dm_pdev.c
index 8917cd56aa6..d08bde89a54 100644
--- a/sys/dev/dm/dm_pdev.c
+++ b/sys/dev/dm/dm_pdev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dm_pdev.c,v 1.19 2019/12/08 12:14:40 mlelstv Exp $ */
+/* $NetBSD: dm_pdev.c,v 1.20 2019/12/13 15:49:22 tkusumi Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.19 2019/12/08 12:14:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dm_pdev.c,v 1.20 2019/12/13 15:49:22 tkusumi Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -174,8 +174,10 @@ dm_pdev_rem(dm_pdev_t *dmp)
if (dmp->pdev_vnode != NULL) {
int error = vn_close(dmp->pdev_vnode, FREAD | FWRITE, FSCRED);
- if (error != 0)
+ if (error != 0) {
+ kmem_free(dmp, sizeof(*dmp));
return error;
+ }
}
kmem_free(dmp, sizeof(*dmp));