From 6645c9ff13f6df3a103930f0d9fd6d7570b53ce3 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 27 Dec 2013 19:17:28 +0000 Subject: [PATCH] from netbsd, free(bbp) in error paths. Coverity CID 274748. via Loganaden Velvindron --- sbin/newfs_ext2fs/mke2fs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbin/newfs_ext2fs/mke2fs.c b/sbin/newfs_ext2fs/mke2fs.c index c3d8f5a81f3..222eb0eab2c 100644 --- a/sbin/newfs_ext2fs/mke2fs.c +++ b/sbin/newfs_ext2fs/mke2fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mke2fs.c,v 1.5 2013/04/17 03:33:13 deraadt Exp $ */ +/* $OpenBSD: mke2fs.c,v 1.6 2013/12/27 19:17:28 deraadt Exp $ */ /* $NetBSD: mke2fs.c,v 1.13 2009/10/19 18:41:08 bouyer Exp $ */ /*- @@ -1262,8 +1262,10 @@ alloc(uint32_t size, uint16_t mode) #endif loc = skpc(~0U, len, bbp); - if (loc == 0) + if (loc == 0) { + free(bbp); return 0; + } loc = len - loc; map = bbp[loc]; bno = loc * NBBY; @@ -1271,6 +1273,7 @@ alloc(uint32_t size, uint16_t mode) if ((map & (1 << i)) == 0) goto gotit; } + free(bbp); return 0; gotit: -- 2.20.1