From patchwork Fri Apr 24 13:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11507863 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B44192A for ; Fri, 24 Apr 2020 13:20:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8B032084D for ; Fri, 24 Apr 2020 13:20:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Wu8YZlRM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727052AbgDXNU1 (ORCPT ); Fri, 24 Apr 2020 09:20:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbgDXNU1 (ORCPT ); Fri, 24 Apr 2020 09:20:27 -0400 Received: from mail-ua1-x94a.google.com (mail-ua1-x94a.google.com [IPv6:2607:f8b0:4864:20::94a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED111C09B045 for ; Fri, 24 Apr 2020 06:20:25 -0700 (PDT) Received: by mail-ua1-x94a.google.com with SMTP id l9so4969098uao.12 for ; Fri, 24 Apr 2020 06:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=r9H1IW1LgtEkP8qLWkbs6oOL83C0+GpU8c93D2C8O+E=; b=Wu8YZlRMt98XgKmsACE1XV5n+dabvH9NmisOPAUZ0ezGdXqMT7BBGBOb9Ng2O42kj+ hibERO+zT/JA3JGDhq+Bu5OKltmrKOmEyKCDtM7Tc3Cr9oOT98JfCGMYuFtiEzuRbgFt vFJtVM1griYhhIpH0n94Z+GLXyzlHtzbwDu0ytT8GiF0bkDL7vEogBQMPThOkApOTGeG tQgdpm06Hf37atZMj4s22ubXfS+RR85cE05v4M/sqCfBwJl+z3T45KEEnZIU2K+3rrjW AUrs1UOTnH18pm/f62KclP3ZifYgNYYaLROml0hWiVTtddpsNq4L9ho9lbWp3MCVyn3C 1e5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=r9H1IW1LgtEkP8qLWkbs6oOL83C0+GpU8c93D2C8O+E=; b=ZxtC+0hx4Ge3aTnFy3wM0zAcg3v1wPseUP40fWCmhbyTZv0ciqDEpIxa3vUwheBkC2 9+XCWd9adiksV1YDyYYUCVb5j0ZtjUAMl0GOvtSVcc4kjTi11TQUca3ESXD7PQ04f6nS sc4zZZSQR66JKAsFcwRxxMqJ8ugdYb/I3mE47MmnLWHDPVNGZIWLo05OAYf3rXh3b1/i oZubul4tdv3Ey03EIerX5tBk91OmiWAqLJxVhKeBgw59LWGGAwqn4vRKUqzJZxa0qQCb pNf8f+gOMjNUaXB0pCDPRI8FP3zm46X8BkhWNvMybJDv4yQKkhH/ZpGw901+5JWrom5O niTg== X-Gm-Message-State: AGi0PuYKNVKXiKx4n5ZWK2mIa+w07hkfz2o7QAbV3gzzB9BH55an7goG prgrtTSo3UuAvcnoJVlBasPI6nrc5wWBZu2J X-Google-Smtp-Source: APiQypLElWOC/iqIxBReE7LPkVfCCE0t6xjkTcKjVSJ7azxEWLCUiTVOs3OH+UJQG5OnKKEI8yAUeQAHcW20bhPU X-Received: by 2002:a1f:99d1:: with SMTP id b200mr7899519vke.95.1587734424795; Fri, 24 Apr 2020 06:20:24 -0700 (PDT) Date: Fri, 24 Apr 2020 15:20:19 +0200 Message-Id: <9c99c508da044822baf53db5e3fccd4f21b0f8d3.1587734346.git.andreyknvl@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog Subject: [PATCH USB v2 1/2] usb: raw-gadget: fix return value of ep read ioctls From: Andrey Konovalov To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Jonathan Corbet , Alan Stern , Dan Carpenter , Andrey Konovalov Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org They must return the number of bytes transferred during the data stage. Fixes: 068fbff4f860 ("usb: raw-gadget: Fix copy_to/from_user() checks") Fixes: f2c2e717642c ("usb: gadget: add raw-gadget interface") Signed-off-by: Andrey Konovalov --- Changes in v2: - Added Fixes tags. --- drivers/usb/gadget/legacy/raw_gadget.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c index ca7d95bf7397..7b241992ad5a 100644 --- a/drivers/usb/gadget/legacy/raw_gadget.c +++ b/drivers/usb/gadget/legacy/raw_gadget.c @@ -669,12 +669,14 @@ static int raw_ioctl_ep0_read(struct raw_dev *dev, unsigned long value) if (IS_ERR(data)) return PTR_ERR(data); ret = raw_process_ep0_io(dev, &io, data, false); - if (ret) + if (ret < 0) goto free; length = min(io.length, (unsigned int)ret); if (copy_to_user((void __user *)(value + sizeof(io)), data, length)) ret = -EFAULT; + else + ret = length; free: kfree(data); return ret; @@ -964,12 +966,14 @@ static int raw_ioctl_ep_read(struct raw_dev *dev, unsigned long value) if (IS_ERR(data)) return PTR_ERR(data); ret = raw_process_ep_io(dev, &io, data, false); - if (ret) + if (ret < 0) goto free; length = min(io.length, (unsigned int)ret); if (copy_to_user((void __user *)(value + sizeof(io)), data, length)) ret = -EFAULT; + else + ret = length; free: kfree(data); return ret; From patchwork Fri Apr 24 13:20:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11507861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E67D192A for ; Fri, 24 Apr 2020 13:20:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC7352084D for ; Fri, 24 Apr 2020 13:20:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="PdCZQPxF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727944AbgDXNUb (ORCPT ); Fri, 24 Apr 2020 09:20:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727930AbgDXNUa (ORCPT ); Fri, 24 Apr 2020 09:20:30 -0400 Received: from mail-vk1-xa4a.google.com (mail-vk1-xa4a.google.com [IPv6:2607:f8b0:4864:20::a4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 493EBC09B046 for ; Fri, 24 Apr 2020 06:20:29 -0700 (PDT) Received: by mail-vk1-xa4a.google.com with SMTP id s206so4579998vke.20 for ; Fri, 24 Apr 2020 06:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=iVEHdoFtCdFpiBaH+7lTMwaiCbL5fq6YQc2JbTG34i0=; b=PdCZQPxFLh4X4g5Ge3zd7n/ltxri3640RXfDg8wJyfnyqccwK4dNf6XCxJUoDtGfHi NCZXLr0l23ePq/mUzsBAqQgrJwLnifk7PHlnEWjWovbaGsSQK+rGwyCMiyvwBJDRWN0H 49TzMZBzZPVhBD5vBJ1BJohRFK0Z9L+dEYCyOBNPAN7eDKYKYwXXiFQUeiiRlwsis2m2 iaKg+XOwjGAF0atcmVy/kJh3248oEYro+CDniEPaSy46WuLqmZymFJqhrkdMb+XaWCu1 syFtzCej7wE791ewsv/Pgujzbyp43R1Rw9h/+xWUqIqo9pJLLB1VCbBOiDUYK79B0AEv Qqbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=iVEHdoFtCdFpiBaH+7lTMwaiCbL5fq6YQc2JbTG34i0=; b=U7Uctx+VuQuUsq5eXhCOCyIBjhLdt+MIcWFbVkQKsaJmRH9KmhS9JQq+3kD3A++yBh AK8SzrmfA3n6J3SP62wOUFJb7mJ8wZugOK+ktK2M8AeiZI7VGdKsDT3ZfUGPJ+Nhzvoq 9mhMI3zXSo/b0q2ECNu8lErRJwvJtjzjxQWjyZkG3pRgljqZpgo2g5bRxrd8svpDwUkm ILtqWZ4+RkOvOX8XIwM44nxgEAYz4C7EtbnCg6K/jfXCpY88u8gzIjHu5mXP23nn+Bqb gqGa93NXSuFdk6j0YTqoFznIOjPGPC7k+Yyr39DuBfIMKslO9xtibs1XrNINIp8lpWOM gYig== X-Gm-Message-State: AGi0PuaMr4XxSGxGsuZClfTCXSltkeUmGNK8GPZhvQ/MKhba2+C9Szfs dTgGnwdv3eQmnyKix/UyiVFxKzBYHA/D/6fG X-Google-Smtp-Source: APiQypKBNnbfnbdI4IQDk1HiBGDGCEt6LytLKochQyMW8Chmj4ToVQPSf3IEhYa2CEKPn1r93OojRJbC1kl5TjKi X-Received: by 2002:a1f:ff11:: with SMTP id p17mr7604647vki.25.1587734428386; Fri, 24 Apr 2020 06:20:28 -0700 (PDT) Date: Fri, 24 Apr 2020 15:20:20 +0200 In-Reply-To: <9c99c508da044822baf53db5e3fccd4f21b0f8d3.1587734346.git.andreyknvl@google.com> Message-Id: <635f48fcb4bb99c70ab9d7f0dfe84d1ec7dc540e.1587734346.git.andreyknvl@google.com> Mime-Version: 1.0 References: <9c99c508da044822baf53db5e3fccd4f21b0f8d3.1587734346.git.andreyknvl@google.com> X-Mailer: git-send-email 2.26.2.303.gf8c07b1a785-goog Subject: [PATCH USB v2 2/2] usb: raw-gadget: fix typo in uapi headers From: Andrey Konovalov To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , Jonathan Corbet , Alan Stern , Dan Carpenter , Andrey Konovalov Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Change "trasferred" into "transferred". Change-Id: I2d8d1dcc9ba6aacafc03f4b76caca7409a6da1a6 --- Changes in v2: - Updated commit message. --- include/uapi/linux/usb/raw_gadget.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/usb/raw_gadget.h b/include/uapi/linux/usb/raw_gadget.h index ea375082b3ac..8544802b25bd 100644 --- a/include/uapi/linux/usb/raw_gadget.h +++ b/include/uapi/linux/usb/raw_gadget.h @@ -119,7 +119,7 @@ struct usb_raw_ep_io { * received on endpoint 0, provided that was an IN (OUT for READ) request and * waits until the urb is completed. Copies received data to user for READ. * Accepts a pointer to the usb_raw_ep_io struct as an argument. - * Returns length of trasferred data on success or negative error code on + * Returns length of transferred data on success or negative error code on * failure. */ #define USB_RAW_IOCTL_EP0_WRITE _IOW('U', 3, struct usb_raw_ep_io) @@ -145,7 +145,7 @@ struct usb_raw_ep_io { * request and waits until the urb is completed. Copies received data to user * for READ. * Accepts a pointer to the usb_raw_ep_io struct as an argument. - * Returns length of trasferred data on success or negative error code on + * Returns length of transferred data on success or negative error code on * failure. */ #define USB_RAW_IOCTL_EP_WRITE _IOW('U', 7, struct usb_raw_ep_io)