Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753377AbbLJGpt (ORCPT ); Thu, 10 Dec 2015 01:45:49 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34949 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791AbbLJGps (ORCPT ); Thu, 10 Dec 2015 01:45:48 -0500 Date: Wed, 9 Dec 2015 22:45:44 -0800 From: Dmitry Torokhov To: Laura Abbott Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCHv3] Input: xpad - Fix double URB submission races Message-ID: <20151210064544.GA35875@dtor-ws> References: <1447714033-13809-1-git-send-email-labbott@fedoraproject.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1447714033-13809-1-git-send-email-labbott@fedoraproject.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1455 Lines: 43 Hi Laura, On Mon, Nov 16, 2015 at 02:47:13PM -0800, Laura Abbott wrote: > +static int __xpad_submit_urb(struct usb_xpad *xpad, > + unsigned char odata[XPAD_PKT_LEN], int transfer_length, > + int type, bool safe_submit) > +{ > + int ret; > + > + if (safe_submit || xpad->submit_state == OUT_IRQ_AVAILABLE) { > + memcpy(xpad->odata, odata, transfer_length); > + xpad->irq_out->transfer_buffer_length = transfer_length; > + ret = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); > + xpad->submit_state = OUT_IRQ_QUEUE_EMPTY; > + xpad->out_submitter = type; > + } else { > + /* > + * The goal here is to prevent starvation of any other type. > + * If this type matches what is being submitted and there is > + * another type in the queue, don't ovewrite it > + */ > + if (xpad->submit_state != OUT_IRQ_QUEUE_EMPTY && > + xpad->out_submitter == type && > + xpad->queue_submitter != type) { > + ret = -EBUSY; > + goto out; No, we do not want to return "busy" here. We should save the most up-to-date request of given type and re-submit it when URB is no longer busy. I CCed you on another patch addressing the same issue, please take a look when you have a chance. Thanks. -- Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/