Re: [Qemu-devel] [PATCH 13/16] ahci: add get_cmd_header helper

2015-06-26 Thread John Snow
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 06/26/2015 11:51 AM, Stefan Hajnoczi wrote: > On Mon, Jun 22, 2015 at 08:21:12PM -0400, John Snow wrote: >> +static AHCICmdHdr *get_cmd_header(AHCIState *s, uint8_t port, >> uint8_t slot) +{ +if (port > s->ports || slot > >> AHCI_MAX_CMDS) {

Re: [Qemu-devel] [PATCH 13/16] ahci: add get_cmd_header helper

2015-06-26 Thread Stefan Hajnoczi
On Mon, Jun 22, 2015 at 08:21:12PM -0400, John Snow wrote: > +static AHCICmdHdr *get_cmd_header(AHCIState *s, uint8_t port, uint8_t slot) > +{ > +if (port > s->ports || slot > AHCI_MAX_CMDS) { Should these be >= instead of >? Otherwise 1 element beyond the end of the array can be accessed.

[Qemu-devel] [PATCH 13/16] ahci: add get_cmd_header helper

2015-06-22 Thread John Snow
cur_cmd is an internal bookmark that points to the current AHCI Command Header being processed by the AHCI state machine. With NCQ needing to occasionally rely on some of the same AHCI helpers, we cannot use cur_cmd and will need to grab explicit pointers instead. In an attempt to begin relying on