Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1612865ybh; Fri, 13 Mar 2020 04:25:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtRwvMy2dY4k33B5Ehx85d7pYRTOkuwYG5/ku+jzzHjH7l9iyAuTjMomWQAW/GzhcZrBPVe X-Received: by 2002:a9d:6251:: with SMTP id i17mr10696648otk.14.1584098758285; Fri, 13 Mar 2020 04:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584098758; cv=none; d=google.com; s=arc-20160816; b=vb9wPgFTvFn7oTxL19AoXT5bDqLsOaC6sS21JWShf8k4Mn2y5jHPa6CctDmucqXmdO bnxKoMIX4gK7t4tK84h8UiYIY9zwQ0cEf5SiBtUwPj0Qq6xGnYXX0+95LHLNMln3nXf2 7any0gDBkEyZOD5xyNG/iVWeDzlcGWIOW6Ul07Vt2+1VQr6hfJambv6WiunmVisvw9bG HXYSz+FVVmm6buqktbWw3f7NcDmhjxMQet7OHCJai5Fd/gSRZwCt9cG+9NlDmy1W+OAC YvHNbEHm9Xk45z2NRhe2CazDGtUWmlbtQ5gQGAJhkJYwXYZ4cyUUvA4c6fgs9DlVpssp Cqvw== 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:to:from :dkim-signature; bh=YSkGa2UvwX+1eAP/7tt1QNSs+cG/P3JEIi8YH4DrwtI=; b=qwVvc4IrDBzvbM1yf+P6zT+yEXB3kEYqUaxG0AnwbjEn/rkJLS2S8AbtOPIGxnQvKF NHno1lx6y58webcojxC7HmkcnRP7oHTeuJWeAhfUV4gCftEebOGXduUByHHDa6BhCdOv LiaCMpnDxabHzcgJkk5t+LinvD2vr9aE8GT/KgX/pYLzk2D2D+fQUqpC5s3Hzb7SlUWL lrqOeo8wPHTlb+xOHkavh44GdRucwPyxdfSWsFI9/ea3oR7yROCY4LXOmI4URRgzuwcJ 7wCzkobZD7iFq8N89rDDvv/v/Pw0ObAKEXpelaDc0DdfQSa8sPtQQskvp45qcJ7ISnnA lxkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ds12Pbz5; 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 b204si3803615oif.69.2020.03.13.04.25.46; Fri, 13 Mar 2020 04:25:58 -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=ds12Pbz5; 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 S1726594AbgCMLZF (ORCPT + 99 others); Fri, 13 Mar 2020 07:25:05 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37226 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726414AbgCMLZF (ORCPT ); Fri, 13 Mar 2020 07:25:05 -0400 Received: by mail-pg1-f196.google.com with SMTP id a32so3968185pga.4; Fri, 13 Mar 2020 04:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=YSkGa2UvwX+1eAP/7tt1QNSs+cG/P3JEIi8YH4DrwtI=; b=ds12Pbz56P3HtbbsNiP4zu8oLtv3DjT0vb9zDsJp975Z7iWT+UKql7Bn1CkRWx/e+Z lhHdDYzzewJ0hOIL29hwJcGLYEwZXnsQQ7j/8DWWJiZ0fq3dt7T5IFczsndvW2IAKj56 6wVOm9bWVjGqxkNIZGRpKm4PXbyb9TyJxux37s3ASVI2BmtOMyvWRtqFSgnRbJZK4xW5 lpGgT5PBTw0HyO559MN+VBkV+5rIvXlP91pA4yLTkQESr8+XQ0zIVB6nhjvlzO9UQ3Wh 7Gjt4KQnntaCUkE/cQ/e0nDuF3SPxxKH0T9EZ5QQhrzMXqJs1JFaJJpz0uJoN+P4YEWM fxjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=YSkGa2UvwX+1eAP/7tt1QNSs+cG/P3JEIi8YH4DrwtI=; b=IhqYapwg6JelL28qmSDpA0pI9LzaMXLk/bSgZlwofNyWYnsmWis942iGbX+OR8J9i+ zOxSf3oMU5zW0ppBe0s7I+IEZYsv7pdL81aIf4FrWYcV/niaZLENwRK7NVFsbWBGB2y0 8lmXgOcTi+Vi5GCX+lUdzJ0q8QyWRHGsPFt6espW39h/nY6eYmx/9erQN2roEAxIx9uN jP20x0ECWxovmd79+H0DXurPjwQ14bjRAjgON0NMUneQITCZfEGvZLL6zhCz0yZ5FDP2 LPs0/bTp/WTqcyMjVxezKfcKxrZ6weABBXYSdxNdzD3ddcUPlKTgXfwYNmxaqBLXEc9O 73bg== X-Gm-Message-State: ANhLgQ0KS/kgwad1CxCWwwkG0Oyn5op6ayuiivU+eigYkiNFnumrfskM HZcJ1M7aRzBfeIn5poorYog= X-Received: by 2002:a63:6944:: with SMTP id e65mr13251443pgc.406.1584098704226; Fri, 13 Mar 2020 04:25:04 -0700 (PDT) Received: from localhost.localdomain ([2405:204:22f:d418:f8a5:7ca8:f99b:fa30]) by smtp.gmail.com with ESMTPSA id q26sm2094820pff.63.2020.03.13.04.24.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2020 04:25:03 -0700 (PDT) From: Shreeya Patel To: adham.abozaeid@microchip.com, ajay.kathat@microchip.com, linux-wireless@vger.kernel.org, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com, sbrivio@redhat.com, daniel.baluta@gmail.com, nramas@linux.microsoft.com, hverkuil@xs4all.nl, shreeya.patel23498@gmail.com Subject: [Outreachy kernel] [PATCH] Staging: wilc1000: cfg80211: Use kmemdup instead of kmalloc and memcpy Date: Fri, 13 Mar 2020 16:54:51 +0530 Message-Id: <20200313112451.25610-1-shreeya.patel23498@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. 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/wilc1000/cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/cfg80211.c b/drivers/staging/wilc1000/cfg80211.c index 54e02807cebf..4bdcbc5fd2fd 100644 --- a/drivers/staging/wilc1000/cfg80211.c +++ b/drivers/staging/wilc1000/cfg80211.c @@ -1142,14 +1142,13 @@ static int mgmt_tx(struct wiphy *wiphy, goto out; } - mgmt_tx->buff = kmalloc(len, GFP_KERNEL); + mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL); if (!mgmt_tx->buff) { ret = -ENOMEM; kfree(mgmt_tx); goto out; } - memcpy(mgmt_tx->buff, buf, len); mgmt_tx->size = len; if (ieee80211_is_probe_resp(mgmt->frame_control)) { -- 2.17.1