Received: from eggs.gnu.org ([2001:4830:134:3::10]:36812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL9fx-0003mO-MK for qemu-devel@nongnu.org; Thu, 07 Jul 2016 09:49:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bL9fu-0001tY-G3 for qemu-devel@nongnu.org; Thu, 07 Jul 2016 09:49:08 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bL9fu-0001s4-8l for qemu-devel@nongnu.org; Thu, 07 Jul 2016 09:49:06 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bL9fo-0004aO-8l for qemu-devel@nongnu.org; Thu, 07 Jul 2016 14:49:00 +0100 From: Peter Maydell Date: Thu, 7 Jul 2016 14:48:56 +0100 Message-Id: <1467899337-19192-6-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1467899337-19192-1-git-send-email-peter.maydell@linaro.org> References: <1467899337-19192-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 5/6] hw/block/m25p80: fix resource leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Shannon Zhao These two are spot by Coverity 1357232 and 1357233. Signed-off-by: Shannon Zhao Message-id: 1467684998-12076-1-git-send-email-zhaoshenglong@huawei.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/block/m25p80.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index d9b2793..ca8c12c 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -459,12 +459,13 @@ static void blk_sync_complete(void *opaque, int ret) static void flash_sync_page(Flash *s, int page) { - QEMUIOVector *iov = g_new(QEMUIOVector, 1); + QEMUIOVector *iov; if (!s->blk || blk_is_read_only(s->blk)) { return; } + iov = g_new(QEMUIOVector, 1); qemu_iovec_init(iov, 1); qemu_iovec_add(iov, s->storage + page * s->pi->page_size, s->pi->page_size); @@ -474,13 +475,14 @@ static void flash_sync_page(Flash *s, int page) static inline void flash_sync_area(Flash *s, int64_t off, int64_t len) { - QEMUIOVector *iov = g_new(QEMUIOVector, 1); + QEMUIOVector *iov; if (!s->blk || blk_is_read_only(s->blk)) { return; } assert(!(len % BDRV_SECTOR_SIZE)); + iov = g_new(QEMUIOVector, 1); qemu_iovec_init(iov, 1); qemu_iovec_add(iov, s->storage + off, len); blk_aio_pwritev(s->blk, off, iov, 0, blk_sync_complete, iov); -- 1.9.1