From patchwork Mon Mar 10 18:30:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 25993 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E99A12054B for ; Mon, 10 Mar 2014 18:33:03 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf19502760pab.2 for ; Mon, 10 Mar 2014 11:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=9PUnUmwloZbOeG61/6WXQw6zViSmchwOKXmyM9sNV3M=; b=iQgvUKKrK211RrxQYUghtQ9hySYgCo7ThMNT3OBIu3y1qcRMiuzttC1MtpcVk634/w i64nwkCcA6n5sxITbeR5/DFWa6OGR5xHwukG3jtvjKxgGFwECo5Rc3qO1oWM/QjL1kPi Va7xbyT0sRByTm+QJnIw5zWoEP1OaSefNDipMhgg/tUe+TKSZnzvvi7is0oFXpkRZ8ui sdocavSfIpApHxjE5xY+d036W27IUoi+yhbr73BMg7M0ZqlzroSEnUrZCBfpJvK09sUR xWY1K98f0YaXOUGRl10Drs31amOTgazSN+z36Z5r/7xSIE4o7X0CMrJFkL05ztTaY3UT NFqQ== X-Gm-Message-State: ALoCoQn1oSf+egq8OUx0ZWTAUzFRNyNwSmV9y1Kwp2XyMXZNXUb90ylj32B2FpjdxjzhEFKkBn+0 X-Received: by 10.66.241.8 with SMTP id we8mr16537242pac.16.1394476383244; Mon, 10 Mar 2014 11:33:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.39 with SMTP id g36ls2242798qgd.25.gmail; Mon, 10 Mar 2014 11:33:03 -0700 (PDT) X-Received: by 10.220.67.18 with SMTP id p18mr23838344vci.14.1394476383054; Mon, 10 Mar 2014 11:33:03 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id xb4si1984267vdc.90.2014.03.10.11.33.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Mar 2014 11:33:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lh14so5372822vcb.6 for ; Mon, 10 Mar 2014 11:33:03 -0700 (PDT) X-Received: by 10.58.201.5 with SMTP id jw5mr23098215vec.6.1394476382950; Mon, 10 Mar 2014 11:33:02 -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.220.78.9 with SMTP id i9csp139253vck; Mon, 10 Mar 2014 11:33:02 -0700 (PDT) X-Received: by 10.66.159.233 with SMTP id xf9mr42487801pab.139.1394476380949; Mon, 10 Mar 2014 11:33:00 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si17603570pbl.153.2014.03.10.11.33.00; Mon, 10 Mar 2014 11:33:00 -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 S1753483AbaCJScy (ORCPT + 3 others); Mon, 10 Mar 2014 14:32:54 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:37536 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753284AbaCJScx (ORCPT ); Mon, 10 Mar 2014 14:32:53 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s2AIWbrQ014610; Mon, 10 Mar 2014 13:32:37 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2AIWaK9020938; Mon, 10 Mar 2014 13:32:36 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Mon, 10 Mar 2014 13:32:36 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2AIWaO1027662; Mon, 10 Mar 2014 13:32:36 -0500 From: Felipe Balbi To: Linux USB Mailing List CC: , , , , Felipe Balbi Subject: [PATCH 3/4] usb: gadget: inode: switch over to memdup_user() Date: Mon, 10 Mar 2014 13:30:55 -0500 Message-ID: <1394476256-2902-4-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1394476256-2902-1-git-send-email-balbi@ti.com> References: <1394476256-2902-1-git-send-email-balbi@ti.com> MIME-Version: 1.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: balbi@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , This patch fixes the following Coccinelle warning: drivers/usb/gadget/inode.c:442:8-15: WARNING \ opportunity for memdup_user Signed-off-by: Felipe Balbi --- drivers/usb/gadget/inode.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index b94c049..b5be6f03 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -439,11 +439,9 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ value = -ENOMEM; - kbuf = kmalloc (len, GFP_KERNEL); - if (!kbuf) - goto free1; - if (copy_from_user (kbuf, buf, len)) { - value = -EFAULT; + kbuf = memdup_user(buf, len); + if (!kbuf) { + value = PTR_ERR(kbuf); goto free1; } @@ -452,7 +450,6 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) data->name, len, (int) value); free1: mutex_unlock(&data->lock); - kfree (kbuf); return value; }