From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbcJDAHt (ORCPT ); Mon, 3 Oct 2016 20:07:49 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:35801 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751678AbcJDAHp (ORCPT ); Mon, 3 Oct 2016 20:07:45 -0400 From: Michal Nazarewicz To: Chen Yu , Felipe Balbi , John Stultz Cc: Greg KH , Biggo Wang , Amit Pundir , Guodong Xu , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Michal Nazarewicz Subject: [PATCH 1/2] usb: gadget: f_fs: edit epfile->ep under lock Date: Tue, 4 Oct 2016 02:07:33 +0200 Message-Id: <1475539654-31945-1-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <205cfce1-d54c-262d-f939-ad9f37b0c52c@huawei.com> References: <205cfce1-d54c-262d-f939-ad9f37b0c52c@huawei.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org epfile->ep is protected by ffs->eps_lock (not epfile->mutex) so clear it while holding the spin lock. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 0aeed85..759f5d4 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1725,17 +1725,17 @@ static void ffs_func_eps_disable(struct ffs_function *func) unsigned long flags; do { - if (epfile) - mutex_lock(&epfile->mutex); spin_lock_irqsave(&func->ffs->eps_lock, flags); /* pending requests get nuked */ if (likely(ep->ep)) usb_ep_disable(ep->ep); ++ep; + if (epfile) + epfile->ep = NULL; spin_unlock_irqrestore(&func->ffs->eps_lock, flags); if (epfile) { - epfile->ep = NULL; + mutex_lock(&epfile->mutex); kfree(epfile->read_buffer); epfile->read_buffer = NULL; mutex_unlock(&epfile->mutex); -- 2.8.0.rc3.226.g39d4020