Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2781939imm; Sun, 17 Jun 2018 04:17:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK6tdMHXu8aGxsWJD+u0zTABDFxJ8ucEOEpaNksmNAJmqW5ovsfn0fV2M8Siz+DdPz2QgUg X-Received: by 2002:a62:4653:: with SMTP id t80-v6mr9206416pfa.58.1529234264807; Sun, 17 Jun 2018 04:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529234264; cv=none; d=google.com; s=arc-20160816; b=KaxzdK90+uHXNrsyygdEr3ZfOnSXibYCUdX1xqW0PW4j76IgcAC6thevbB8z4Sm/T6 nhRs61CV4nc4rlsHBVPpcgWp6HiPGqLt0AF9g3drQND2bvOBaHWotobZrT4xk/dGUvfq NOXnsbDa+Lg5twBjKWFoSlgjyf8ovMxMrL5FLc53wVoWv8FUOAUd+DYg5ed+4iW8VPNJ cZkODidVDER4oCmHSmzalcbN37TNDUvzJBOMmYKyy+IUTRNkxfajpCEfG+mZZyTnG+K1 Nmi+0uB9PPWz3I6HMkdkIuohYG2LciRfvHqR4FwKEzI+VbBmJwxy2B1N48DzMNpy4qnP G0Cw== 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=XbyL4z96xfT3YlWw8BGvtGOlSct9gr9UlwfO+ED5Xsc=; b=Ob6tV5pBAIddNGCbVEruuiw0DfBDoIN5M7He9dmlAO9s7AIad0LYwLK7VKTIsbs64r 2SjAQz3Mn2542sAahLgeJ/Rqg4YmXtKxZM9AcCW3yqhn3ZfRVFzPt9cr11LmxF1l0khK tuu3t+yCom2nsRWlM9C01DpGvDtanvAdugoAlWYOFIerx/5dDKYRdaxq51CLEPCBS9+R BJkj5phVpcYJhkfGqHgcDbikdroupAUXBANHbDhutCRIwLTR56C3Nvkm51FROJfXV4E7 wjrHYAFb5X1z9TCfZZFqUW8tZb0n788KQHibvgwSpFubPIaTva2tgTnsjbP4Rcp4JUEX e+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=klak7P7s; 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=QUARANTINE 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 p9-v6si12352839plo.208.2018.06.17.04.17.30; Sun, 17 Jun 2018 04:17:44 -0700 (PDT) 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=klak7P7s; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933194AbeFQLRD (ORCPT + 99 others); Sun, 17 Jun 2018 07:17:03 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:44413 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754255AbeFQLRC (ORCPT ); Sun, 17 Jun 2018 07:17:02 -0400 Received: by mail-pf0-f194.google.com with SMTP id h12-v6so6834376pfk.11 for ; Sun, 17 Jun 2018 04:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=XbyL4z96xfT3YlWw8BGvtGOlSct9gr9UlwfO+ED5Xsc=; b=klak7P7sqevcta86Mmxlo42WJKai1jIZBm5JVtr0b5GuvpDWtZKxChIUx3Jx/P7FYT JaKcouNxCccIt7qWJICndlqXq7tCPugLoDrO7bjt76kWgYeCac70uXWdpiQrFuBzZNbi nocsRCv4urJgiZLWNKqSaK+MDsWIXvhGCjskpzHbhiOquoQ3oeYINij07Orl98kos5Iu 0NxqOWAOH0gH0xM5SsuFIAlDX8LKgMA4F8TkdV3gbw4ItKwL4VVG0GDAPfSxV4sJu6BP ilagHJqvLYblEn8wDXxWLVgcT4J1h6nltNQtPy/0GLNmDtaR+Dm+YZrnj9G9X1mwNsef JKsw== 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=XbyL4z96xfT3YlWw8BGvtGOlSct9gr9UlwfO+ED5Xsc=; b=WeG2Fexr87X+g/6ZYD32UJbKKeY8NvIHvvrulMe9x3hZQqncsMchYSfYg0DYsVzul3 v4wDEU/rky8rB8A7V4+78CXboiWfvZRJFET/CtQsRrq7rRFSQznCfPnViOZVjxqAWq0l bjXvl8S6b8rh7d/MVxqnVI8ylL9IlqKS774oE0S8Qg7TzV2BWZA9dOkfPTxZYTkv6pFH WXi5qfsVXbNnwUe6ew2k4SdJXhcXqjrNS2sDIKQSzd71evL11VuXuZXYFT7NHDPgHTxZ CNsRJdFPhYjQmbilGhu465e/wNqNkj1DciDzPnppJi03AWMKTg9p5TB7XKhVqwbyYkhj WP/A== X-Gm-Message-State: APt69E1pa7+UbnOF+zg5MrluMkiTWoTaHIogCPD1tiuzg7a6Du6RPiI8 fdpVRqeDa23kuS7CG290aPuFnQ== X-Received: by 2002:a65:56c1:: with SMTP id w1-v6mr7724265pgs.227.1529234222202; Sun, 17 Jun 2018 04:17:02 -0700 (PDT) Received: from shreeya-VirtualBox ([103.212.140.156]) by smtp.gmail.com with ESMTPSA id o65-v6sm16178047pga.75.2018.06.17.04.17.00 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 04:17:01 -0700 (PDT) From: Shreeya Patel To: oleg.drokin@intel.com, andreas.dilger@intel.com, jsimmons@infradead.org, gregkh@linuxfoundation.org, lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Shreeya Patel Subject: [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy Date: Sun, 17 Jun 2018 16:46:55 +0530 Message-Id: <1529234215-4010-1-git-send-email-shreeya.patel23498@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace calls to kzalloc or kmalloc followed by a memcpy with a direct call to kmemdup to shorten the code. The Coccinelle semantic patch used to make this change is as follows: @@ expression from,to,size,flag; statement S; @@ - to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || ...) S - memcpy(to, from, size); Signed-off-by: Shreeya Patel --- drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index f9ed697..36ea14e 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1271,15 +1271,14 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf) lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk; if (lnd_tunables) { - ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables), + ni->ni_lnd_tunables = kmemdup(lnd_tunables, + sizeof(*ni->ni_lnd_tunables), GFP_NOFS); if (!ni->ni_lnd_tunables) { mutex_unlock(&the_lnet.ln_lnd_mutex); rc = -ENOMEM; goto failed0; } - memcpy(ni->ni_lnd_tunables, lnd_tunables, - sizeof(*ni->ni_lnd_tunables)); } /* -- 2.7.4