From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wk8KX-00053Q-70 for qemu-devel@nongnu.org; Tue, 13 May 2014 04:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wk8KQ-0002sT-Nt for qemu-devel@nongnu.org; Tue, 13 May 2014 04:44:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wk8KQ-0002rY-HE for qemu-devel@nongnu.org; Tue, 13 May 2014 04:44:50 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4D8in8r008887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 May 2014 04:44:49 -0400 Message-ID: <1399970685.7118.45.camel@nilsson.home.kraxel.org> From: Gerd Hoffmann Date: Tue, 13 May 2014 10:44:45 +0200 In-Reply-To: <20140513083214.GD29442@redhat.com> References: <1399896829-16617-1-git-send-email-mst@redhat.com> <1399967409.7118.38.camel@nilsson.home.kraxel.org> <20140513083214.GD29442@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] usb: fix up post load checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org, dgilbert@redhat.com On Di, 2014-05-13 at 11:32 +0300, Michael S. Tsirkin wrote: > On Tue, May 13, 2014 at 09:50:09AM +0200, Gerd Hoffmann wrote: > > Hi, > > > > > + (dev->setup_state == SETUP_STATE_DATA && > > > > Fails to build, SETUP_STATE_DATA is not defined here. > > > > I think we can simply drop that check, index should never ever be larger > > than len, no matter what the state is. > > > > cheers, > > Gerd > > I'm confused by usb_generic_async_ctrl_complete which can modify len > without touching index. only in setup state, before any data from/to the buffer is transfered, so index is still zero at that point. flow is this: state_setup: len = $buflen, index = 0 state_data: xfer %buf data, increase index up to len while doing so. state_ack: index == len state_idle: likewise. cheers, Gerd