From patchwork Wed May 20 13:53:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Miguel Silva X-Patchwork-Id: 48801 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E1B9A2121F for ; Wed, 20 May 2015 13:53:44 +0000 (UTC) Received: by lagr1 with SMTP id r1sf17676464lag.3 for ; Wed, 20 May 2015 06:53:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=kKtW5Ws88XP4t4tUwr1BaWqOVte1Nq0jHAxw3NAYh1o=; b=dZiFzafPfxfWEQ0BtRcILSbcudQixvMZtYaeZ/uf5SY/A8NMov6k+ykIdq7Fj1zRIl I6es3EVYGNoL8rYUKMHmEDgKeMNy3Kqcd+/0Q7EAwczqOgFEthydkgbZpgt5EMT0fXMN Iip5XM/m4K9pde8T9O5Vnc1IjSvWNfYBqfWah6I7b2V4LqcbZ+IObVH1Yv12z8IFtQG/ C8xjzM/T0HPvYHc8Uxf4UQfpq/u2+Fd7bxL7dgqJyhWzosawbzwZ5elHq0S7SainLNee 8nO6joXmW4VOOQtbVqYFFR7Oa7C7UWl/3fvaNSTAMlLuvszlfkrnzBvXeG/BEGgwxEHF 1luw== X-Gm-Message-State: ALoCoQn6yn/V0r4d2/wOCi6Z7SRQXRHraguknJVPpPMyen88t6m7jmDN74wgP6pUa/NxaYPPjdsr X-Received: by 10.194.143.98 with SMTP id sd2mr26599575wjb.6.1432130023808; Wed, 20 May 2015 06:53:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.73 with SMTP id i9ls197036lai.100.gmail; Wed, 20 May 2015 06:53:43 -0700 (PDT) X-Received: by 10.112.219.201 with SMTP id pq9mr26000247lbc.109.1432130023642; Wed, 20 May 2015 06:53:43 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id bd3si11212352lab.77.2015.05.20.06.53.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2015 06:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laat2 with SMTP id t2so74693201laa.1 for ; Wed, 20 May 2015 06:53:43 -0700 (PDT) X-Received: by 10.152.2.227 with SMTP id 3mr26026266lax.73.1432130023513; Wed, 20 May 2015 06:53:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1547949lbb; Wed, 20 May 2015 06:53:42 -0700 (PDT) X-Received: by 10.68.57.164 with SMTP id j4mr21951739pbq.63.1432130021812; Wed, 20 May 2015 06:53:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bk1si26630297pad.104.2015.05.20.06.53.40; Wed, 20 May 2015 06:53:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752540AbbETNxj (ORCPT + 4 others); Wed, 20 May 2015 09:53:39 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:33553 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbbETNxj (ORCPT ); Wed, 20 May 2015 09:53:39 -0400 Received: by wicmx19 with SMTP id mx19so150501339wic.0 for ; Wed, 20 May 2015 06:53:38 -0700 (PDT) X-Received: by 10.180.160.169 with SMTP id xl9mr19006655wib.42.1432130017986; Wed, 20 May 2015 06:53:37 -0700 (PDT) Received: from arch-late.dtvresearch.loc (a95-92-118-66.cpe.netcabo.pt. [95.92.118.66]) by mx.google.com with ESMTPSA id gj7sm3626811wib.4.2015.05.20.06.53.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 May 2015 06:53:37 -0700 (PDT) From: Rui Miguel Silva To: Felipe Balbi Cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , Rui Miguel Silva Subject: [PATCH] usb: gadget: f_fs: fix check in read operation Date: Wed, 20 May 2015 14:53:33 +0100 Message-Id: <1432130013-22002-1-git-send-email-rui.silva@linaro.org> X-Mailer: git-send-email 2.4.0 Sender: linux-usb-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rui.silva@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , when copying to iter the size can be different then the iov count, the check for full iov is wrong and make any read on request which is not the exactly size of iov to return -EFAULT. So, just check the success of the copy. Signed-off-by: Rui Miguel Silva --- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 8f893cd..b07e2ae 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -847,7 +847,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) ret = ep->status; if (io_data->read && ret > 0) { ret = copy_to_iter(data, ret, &io_data->data); - if (unlikely(iov_iter_count(&io_data->data))) + if (!ret) ret = -EFAULT; } }