Received: from eggs.gnu.org ([2001:4830:134:3::10]:43420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9t1G-0001Ya-PJ for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:48:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9t19-00082k-M3 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:48:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9t19-00082d-G5 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 07:48:27 -0400 Date: Mon, 6 Jun 2016 17:18:13 +0530 (IST) From: P J P In-Reply-To: <1464694581-31596-1-git-send-email-ppandit@redhat.com> Message-ID: References: <1464694581-31596-1-git-send-email-ppandit@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH v2] scsi: esp: check TI buffer index before read/write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu Developers Cc: Li Qiang , Peter Maydell , Huawei PSIRT , Paolo Bonzini +-- On Tue, 31 May 2016, P J P wrote --+ | switch (saddr) { | case ESP_FIFO: | - if (s->ti_size > 0) { | + if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) { | + /* Data out. */ | + qemu_log_mask(LOG_UNIMP, "esp: PIO data read not implemented\n"); | + s->rregs[ESP_FIFO] = 0; | + esp_raise_irq(s); | + } else if (s->ti_rptr < s->ti_wptr) { | s->ti_size--; | - if ((s->rregs[ESP_RSTAT] & STAT_PIO_MASK) == 0) { | - /* Data out. */ | - qemu_log_mask(LOG_UNIMP, | - "esp: PIO data read not implemented\n"); | - s->rregs[ESP_FIFO] = 0; | - } else { | - s->rregs[ESP_FIFO] = s->ti_buf[s->ti_rptr++]; | - } | + s->rregs[ESP_FIFO] = s->ti_buf[s->ti_rptr++]; | esp_raise_irq(s); | } | if (s->ti_size == 0) { | @@ -456,7 +454,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) | } else { | trace_esp_error_fifo_overrun(); | } | - } else if (s->ti_size == TI_BUFSZ - 1) { | + } else if (s->ti_wptr == TI_BUFSZ - 1) { | trace_esp_error_fifo_overrun(); | } else { | s->ti_size++; Ping..! -- Prasad J Pandit / Red Hat Product Security Team 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F