From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbcADVmC (ORCPT ); Mon, 4 Jan 2016 16:42:02 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:32849 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753368AbcADVly (ORCPT ); Mon, 4 Jan 2016 16:41:54 -0500 From: Michal Nazarewicz To: Felipe Balbi , "Du, Changbin" Cc: Greg Kroah-Hartman , Al Viro , Robert Baldyga , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Nazarewicz Subject: [PATCH 2/5] usb: f_fs: fix ffs_epfile_io returning success on req alloc failure Date: Mon, 4 Jan 2016 22:41:38 +0100 Message-Id: <1451943701-18212-2-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 In-Reply-To: <1451943701-18212-1-git-send-email-mina86@mina86.com> References: <1451943701-18212-1-git-send-email-mina86@mina86.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the AIO path, if allocating of a request failse, the function simply goes to the error_lock path whose end result is returning value of ret. However, at this point ret’s value is zero (assigned as return value from ffs_mutex_lock). Fix by adding ‘ret = -ENOMEM’ statement. Signed-off-by: Michal Nazarewicz --- drivers/usb/gadget/function/f_fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index d1a4a86..1384220 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -793,8 +793,10 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) if (io_data->aio) { req = usb_ep_alloc_request(ep->ep, GFP_KERNEL); - if (unlikely(!req)) + if (unlikely(!req)) { + ret = -ENOMEM; goto error_lock; + } req->buf = data; req->length = data_len; -- 2.6.0.rc2.230.g3dd15c0