Received: from eggs.gnu.org ([2001:4830:134:3::10]:47120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQpQ-00027k-Mn for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPQpP-0007sb-HI for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPQpP-0007sT-9g for qemu-devel@nongnu.org; Tue, 19 Jul 2016 04:56:35 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CECC0811A2 for ; Tue, 19 Jul 2016 08:56:34 +0000 (UTC) From: marcandre.lureau@redhat.com Date: Tue, 19 Jul 2016 12:54:31 +0400 Message-Id: <20160719085432.4572-37-marcandre.lureau@redhat.com> In-Reply-To: <20160719085432.4572-1-marcandre.lureau@redhat.com> References: <20160719085432.4572-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 36/37] ahci: fix sglist leak on retry List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-Andr=C3=A9 Lureau ahci-test /x86_64/ahci/io/dma/lba28/retry triggers the following leak: Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7fc4b2a25e20 in malloc (/lib64/libasan.so.3+0xc6e20) #1 0x7fc4993bce58 in g_malloc (/lib64/libglib-2.0.so.0+0x4ee58) #2 0x556a187d4b34 in ahci_populate_sglist hw/ide/ahci.c:896 #3 0x556a187d8237 in ahci_dma_prepare_buf hw/ide/ahci.c:1367 #4 0x556a187b5a1a in ide_dma_cb hw/ide/core.c:844 #5 0x556a187d7eec in ahci_start_dma hw/ide/ahci.c:1333 #6 0x556a187b650b in ide_start_dma hw/ide/core.c:921 #7 0x556a187b61e6 in ide_sector_start_dma hw/ide/core.c:911 #8 0x556a187b9e26 in cmd_write_dma hw/ide/core.c:1486 #9 0x556a187bd519 in ide_exec_cmd hw/ide/core.c:2027 #10 0x556a187d71c5 in handle_reg_h2d_fis hw/ide/ahci.c:1204 #11 0x556a187d7681 in handle_cmd hw/ide/ahci.c:1254 #12 0x556a187d168a in check_cmd hw/ide/ahci.c:510 #13 0x556a187d0afc in ahci_port_write hw/ide/ahci.c:314 #14 0x556a187d105d in ahci_mem_write hw/ide/ahci.c:435 #15 0x556a1831d959 in memory_region_write_accessor /home/elmarco/src/= qemu/memory.c:525 #16 0x556a1831dc35 in access_with_adjusted_size /home/elmarco/src/qem= u/memory.c:591 #17 0x556a18323ce3 in memory_region_dispatch_write /home/elmarco/src/= qemu/memory.c:1262 #18 0x556a1828cf67 in address_space_write_continue /home/elmarco/src/= qemu/exec.c:2578 #19 0x556a1828d20b in address_space_write /home/elmarco/src/qemu/exec= .c:2635 #20 0x556a1828d92b in address_space_rw /home/elmarco/src/qemu/exec.c:= 2737 #21 0x556a1828daf7 in cpu_physical_memory_rw /home/elmarco/src/qemu/e= xec.c:2746 #22 0x556a183068d3 in cpu_physical_memory_write /home/elmarco/src/qem= u/include/exec/cpu-common.h:72 #23 0x556a18308194 in qtest_process_command /home/elmarco/src/qemu/qt= est.c:382 #24 0x556a18309999 in qtest_process_inbuf /home/elmarco/src/qemu/qtes= t.c:573 #25 0x556a18309a4a in qtest_read /home/elmarco/src/qemu/qtest.c:585 #26 0x556a18598b85 in qemu_chr_be_write_impl /home/elmarco/src/qemu/q= emu-char.c:387 #27 0x556a18598c52 in qemu_chr_be_write /home/elmarco/src/qemu/qemu-c= har.c:399 #28 0x556a185a2afa in tcp_chr_read /home/elmarco/src/qemu/qemu-char.c= :2902 #29 0x556a18cbaf52 in qio_channel_fd_source_dispatch io/channel-watch= .c:84 Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/ide/ahci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 6defeed..0ea5805 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -919,6 +919,7 @@ static void ncq_err(NCQTransferState *ncq_tfs) ide_state->error =3D ABRT_ERR; ide_state->status =3D READY_STAT | ERR_STAT; ncq_tfs->drive->port_regs.scr_err |=3D (1 << ncq_tfs->tag); + qemu_sglist_destroy(&ncq_tfs->sglist); ncq_tfs->used =3D 0; } =20 @@ -1330,6 +1331,7 @@ static void ahci_start_dma(IDEDMA *dma, IDEState *s= , AHCIDevice *ad =3D DO_UPCAST(AHCIDevice, dma, dma); DPRINTF(ad->port_no, "\n"); s->io_buffer_offset =3D 0; + qemu_sglist_destroy(&s->sg); dma_cb(s, 0); } =20 --=20 2.9.0