Received: by 10.223.164.202 with SMTP id h10csp309153wrb; Wed, 22 Nov 2017 07:32:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMaMe/gVLQl7m8ShBfKmq3mFf+k3SO+RuraWH3KYkjKzwE6KWYHXB9M1BmjaWppsO96iVrHB X-Received: by 10.98.24.207 with SMTP id 198mr19643671pfy.3.1511364755385; Wed, 22 Nov 2017 07:32:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511364755; cv=none; d=google.com; s=arc-20160816; b=MEPbMDP4Rf+3YFzr7mVa7VZZ/amdRNf1E9HMTGVgkBECQ4Hkb0BON5W5QPJrXqHyah 1WFrXpunOvGaIuOhdpnsVoy/D+UmxP/WcU/RDKoClp59ifaO7Ji1LsWR2AukpE/z/f4L 42mgUvtsBMEPjyy5dM1mLovT84s2GCjZCwsDLdlvTOEz7V9vDZ7gdoP6HBSYy167bCPN vvv4dgpray/aEe+TD6fysQJMebiv9s2PleCBId+nKLM+GpSsFxbTNpUr9ehAqDzvWxu3 uPpdevRGithU6qkZbfTr0hkqVFFOG31P3y6LsU+Kgc0qpqYQ2JUQTA+2SCSoHkgPZ1Oq X/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=IZlVffKqxK/fKULaWkyCtoJP8FzgWmHJPLxEFobAHtM=; b=kBGmSL3sRwrMiSIlwQ4fn0MtcSzrNiglp+b1wfcEceV8GHn4nn8wlDhB9SYJekOiSK pVcGCR2ibzUa5f/PD+IDFIC57ins/7DRE/5yrPl85YocuUh0ZvIJUoJMTc91SQo3r050 7Bcl9xpVv9ankhQeLaKL+WoY8Dn03AHtpf3tNqUzu5h/7VTy+rxWiLrYB17FYmW5cOaH 9UhMIcsOPIY0ls6Ay6N8rJmqWlm6L5p6mPb/TKdmKwvuQYWDBwiiGQmI+cpqOBs6EDmM l6yetyqnrsRfTns0WXw/8ArAJBkYZC6SiK1l8SLVJStg1+Al3DC157TEMX8uax+gDdNt KSgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kMIT8BMx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a18si14068926plm.225.2017.11.22.07.32.23; Wed, 22 Nov 2017 07:32:35 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=kMIT8BMx; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751797AbdKVPaJ (ORCPT + 77 others); Wed, 22 Nov 2017 10:30:09 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:41679 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751650AbdKVPaH (ORCPT ); Wed, 22 Nov 2017 10:30:07 -0500 Received: by mail-lf0-f68.google.com with SMTP id f134so18670285lfg.8; Wed, 22 Nov 2017 07:30:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=IZlVffKqxK/fKULaWkyCtoJP8FzgWmHJPLxEFobAHtM=; b=kMIT8BMxXvd7Td2qgVlAIXaS208Xy2C0GaM1JkAuXCGABx8IqZ5kEsMT8MtF7PEMT9 C5UUpiiT1GGuwiwomTBs+urkKeLYqvP/r7+323jnC5j/44g8yIvBYWeQEQXjaPFnDn53 mlzxFrTr4TBzqUSD22bNEwdASPJLe7wFNNYmnretgfhdz20H/4vXN/SZAtgIPy1UYHFc JjMg7Aer+5pbrgk2XtrMKsCsPADchsFUfcMpD0al4Jo9tljJtdZEN8z25SEKw/pUJqUV GtOczqNU1QWF5vMqOwJrm6nwSq1VAPjty2X7OX1iJu9Og3SUMM9vLhrFLNEZBUunBsnK neCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IZlVffKqxK/fKULaWkyCtoJP8FzgWmHJPLxEFobAHtM=; b=s3KykIOMh6VjlUWz6h53gQce9onUSl6LSeJ0DeNGWwpbGJSncqKmtKkvVSSjtphgms 1F77JmaEI3U3zYA1ysfcbxNwzq/nrUvgYaFpGREeZj24N9vax3/tI5CphYoPktR/4u3S HUI1d+M9pwVdt/guIRKigKdGPFBeLsquRZPH/Y59MrWjkv3hEzKOo4yTYAKhe00VaA6G elK2hTLYSzj3Sr0Oqd0RiQ8soNOnKf44+9EI8B/2B5rh8Q3BP4sc8K8OeRkjcKe6ntCS 4bdb4k7b14pw/iRuE34buKqedRwKlCtfzhiqJG2d9+dD3IG5aJG+GchQGCBYcoO1poib BWnA== X-Gm-Message-State: AJaThX4FvvJEAjYsFfSkVyW+h9TZN1bn14P6ExANbj6rvzK+8+OBmDr9 ruejeUU+CR9Zurt1sEYs4wFIvzT7 X-Received: by 10.25.158.210 with SMTP id h201mr6832951lfe.177.1511364606094; Wed, 22 Nov 2017 07:30:06 -0800 (PST) Received: from localhost.localdomain ([195.254.138.66]) by smtp.gmail.com with ESMTPSA id u11sm3743084lju.83.2017.11.22.07.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Nov 2017 07:30:05 -0800 (PST) From: Vasyl Gomonovych To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, gomonovych@gmail.com Subject: [PATCH] [WAN]: lmc: Use memdup_user() as a cleanup Date: Wed, 22 Nov 2017 16:29:57 +0100 Message-Id: <1511364597-20915-1-git-send-email-gomonovych@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix coccicheck warning which recommends to use memdup_user(): drivers/net/wan/lmc/lmc_main.c:497:27-34: WARNING opportunity for memdup_user Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci Signed-off-by: Vasyl Gomonovych --- drivers/net/wan/lmc/lmc_main.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 4698450c77d1..ded78a466fe3 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -494,18 +494,11 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - data = kmalloc(xc.len, GFP_KERNEL); - if (!data) { - ret = -ENOMEM; + data = memdup_user(xc.data, xc.len); + if (IS_ERR(data)) { + ret = PTR_ERR(data); break; } - - if(copy_from_user(data, xc.data, xc.len)) - { - kfree(data); - ret = -ENOMEM; - break; - } printk("%s: Starting load of data Len: %d at 0x%p == 0x%p\n", dev->name, xc.len, xc.data, data); -- 1.9.1 From 1585346170887432971@xxx Tue Nov 28 21:18:45 +0000 2017 X-GM-THRID: 1585346170887432971 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread