Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp151149img; Tue, 19 Mar 2019 20:32:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqytPyzBWOZkB+uTYDHP6/+WwvCDr1qh6baZf7Wn4gz3/RAtJEN8QT7Mb9zomT3W3RqXtvpX X-Received: by 2002:a62:fb10:: with SMTP id x16mr5866890pfm.5.1553052723160; Tue, 19 Mar 2019 20:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553052723; cv=none; d=google.com; s=arc-20160816; b=JqdedQT67SiD/ZPCiSV7LdjecTRGJcYZePyjQudbWipI6f+RlQYAp0gqJbo9/vpPXM hBPpShC+hJUAD/mQU2Vsc5mRgkG+Wwi+9I4aGd53JuzljcS7us1x8KawGe1x25r625ab 2LLPKu+39u3uKgAtwhLmEV9tl+4pMP7tpy7zS5LQk33z+H0NFygoR0NvQ14+hU2h6Jhq 9gSlBhUKO7oN6JQazQuKHagLI4+QwYrF1YQFQvAPvVyz9qW8escymuqi3UewO2h9u9If hU41LmLsQXgsnOwZbWqR+uR0N9dXGzqH0SwiXIQsZDB6igz5ffK7sHzMj+1C5qEDVxx0 e/Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=xfWJUPLLORkux5ngMiATjrAgNNYHGlaXDfcmkE4iC9I=; b=YxtFXB72MnvsbeqgiOBwCdyCQDEFT7I3fMU5sLxMZDp1f3Pq1I+OzMBwc6cAmx3Wnr Q7ww2xrExJWsgBV1cMnHaKKsztiChjC70MfknCg6iXxkQDPg8YrCrflgD3b2fUjdtIrZ Utf9pVZx1dvrSGhRH79NaNsweLrJqtuIGEE/++YemUHuW7o4TlGINCorsVu3P4nkgQ0O Lpu9AR9G4MG/Ul0xHJFsxbnvX2HfLMeHg2mIdYaPUXvDIvldBm4LoPYoGDK1ZPKKxL/e l6rHWxNgQU0erv8EC1goy58E2Js+q8nbZpLTXUHXJ7vbztn2o4v/1W2054atSgYD4UoC aXnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=avOOWjDE; dkim=pass header.i=@codeaurora.org header.s=default header.b=eKO549Gw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si772722pls.432.2019.03.19.20.31.45; Tue, 19 Mar 2019 20:32:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=avOOWjDE; dkim=pass header.i=@codeaurora.org header.s=default header.b=eKO549Gw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727405AbfCTDbH (ORCPT + 99 others); Tue, 19 Mar 2019 23:31:07 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51422 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbfCTDbH (ORCPT ); Tue, 19 Mar 2019 23:31:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2249D60E59; Wed, 20 Mar 2019 03:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553052666; bh=jiXsFQhQNUbq4WnRHEcC3kDX/VbVeMW7Okj6NBywH/k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=avOOWjDExOOpMj4o/eeIqyqBqOGbZyup+AwtyPKCL7VbdlSMrTmZb1t6Qg9ZOLJv/ DwJv5BE39oe3fUcTQyionn+8DcXceXGJun0j1DKBIZLb1A8RBPz3GWaMCPmw2dtnjq UhrdW8eVPcENKUXiSxXZOWuYA6haN7d8HH+etmug= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 2ED3160850; Wed, 20 Mar 2019 03:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553052665; bh=jiXsFQhQNUbq4WnRHEcC3kDX/VbVeMW7Okj6NBywH/k=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eKO549Gwa+S/JzVrYuMGQuYkRsb7TOaDBupCjrM3+jy0mZNGRGjLBlKAYSng6tuOV wBnOj5dZosmiwORqJFyXwbrTJyRFWXijUTzTU9AzDj7wSO929J2R2bQidGX8k2V0n+ YEQuEUknjTj+JzUrzxHg1xJfAh3krZi4Jl4WU1ww= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 20 Mar 2019 09:01:05 +0530 From: mgautam@codeaurora.org To: fei.yang@intel.com Cc: balbi@kernel.org, gregkh@linuxfoundation.org, zhangjerry@google.com, andrzej.p@collabora.com, plr.vincent@gmail.com, jingx.shen@intel.com, john.stultz@linaro.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb-owner@vger.kernel.org Subject: Re: [PATCH] usb: gadget: f_fs: don't free buffer prematurely In-Reply-To: <1553037915-85931-1-git-send-email-fei.yang@intel.com> References: <1553037915-85931-1-git-send-email-fei.yang@intel.com> Message-ID: X-Sender: mgautam@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-03-20 04:55, fei.yang@intel.com wrote: > From: Fei Yang > > The following kernel panic happens due to the io_data buffer gets > deallocated > before the async io is completed. Add a check for the case where > io_data buffer > should be deallocated by ffs_user_copy_worker. [snip] Please add tag - 'Fixes: 772a7a724f6 ("usb: gadget: f_fs: Allow scatter-gather buffers") > --- > drivers/usb/gadget/function/f_fs.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/f_fs.c > b/drivers/usb/gadget/function/f_fs.c > index 20413c2..47be961 100644 > --- a/drivers/usb/gadget/function/f_fs.c > +++ b/drivers/usb/gadget/function/f_fs.c > @@ -1133,7 +1133,8 @@ static ssize_t ffs_epfile_io(struct file *file, > struct ffs_io_data *io_data) > error_mutex: > mutex_unlock(&epfile->mutex); > error: > - ffs_free_buffer(io_data); > + if (ret != -EIOCBQUEUED) /* don't free if there is iocb queued */ > + ffs_free_buffer(io_data); > return ret; > }