Received: from eggs.gnu.org ([2001:4830:134:3::10]:43761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpX2-0003fb-EQ for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCpWt-0004m9-9s for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:32:28 -0400 Received: from mail-wg0-x233.google.com ([2a00:1450:400c:c00::233]:34756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpWt-0004m5-3S for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:32:19 -0400 Received: by mail-wg0-f51.google.com with SMTP id b13so2654324wgh.22 for ; Thu, 31 Jul 2014 05:32:16 -0700 (PDT) Date: Thu, 31 Jul 2014 13:32:12 +0100 From: Stefan Hajnoczi Message-ID: <20140731123212.GT25929@stefanha-thinkpad.redhat.com> References: <1404757089-4836-1-git-send-email-jsnow@redhat.com> <1404757089-4836-18-git-send-email-jsnow@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EcLUEBHJhOmOUQ0C" Content-Disposition: inline In-Reply-To: <1404757089-4836-18-git-send-email-jsnow@redhat.com> Subject: Re: [Qemu-devel] [PATCH 17/28] ahci: construct PIO Setup FIS for PIO commands List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com --EcLUEBHJhOmOUQ0C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 07, 2014 at 02:17:58PM -0400, John Snow wrote: > +static void ahci_write_fis_pio(AHCIDevice *ad, uint16_t len) > +{ > + AHCIPortRegs *pr = &ad->port_regs; > + uint8_t *pio_fis, *cmd_fis; > + uint64_t tbl_addr; > + dma_addr_t cmd_len = 0x80; > + > + if (!ad->res_fis || !(pr->cmd & PORT_CMD_FIS_RX)) { > + return; > + } > + > + /* map cmd_fis */ > + tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr); > + cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len, > + DMA_DIRECTION_TO_DEVICE); We should check cmd_len == 0x80 and cmd_fis != NULL to avoid undefined behavior when accessing cmd_fis. --EcLUEBHJhOmOUQ0C Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJT2jdMAAoJEJykq7OBq3PIL5oIALaZGQt+g27hDmKpYVXCTRKX /mNXNPKKZkTMtKhI0i95G6HvXvV5nOSrusqaAeiiWq8BAltjO/lAEjVxoosPAzXi VZxrMkxtNrE9EcHD+AORL3z4fEc85pXHuRpIfZKVul7ppL1UNW/yVzVsxZcK9mFX +l4LOxD/HzRI3QoiCFrJv0yoUwNxkwXK4knXtJvQAXQR9x5NLBWUOwq6Ss8wo4Cd /wXEK98mOPW6nMeDrMQDm7BrBZ7u4sH4Mcy1BkPdjd0aguEVnmwu3J9rzK2CUHfd Y49jXDioSwWIlC9HjZmsu85jx7sI5x/5ahdQygFhODaofSNTdxx1M0sG9LZLpuk= =UcAI -----END PGP SIGNATURE----- --EcLUEBHJhOmOUQ0C--