Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1229110ybh; Sat, 3 Aug 2019 21:08:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCXLFp4O/iwkEC8sT5f1u2ewB0Qj6ZtEZOdrjgw64cYUaIJOiZ5EfQgetpAwYXg45j7hy7 X-Received: by 2002:a65:6415:: with SMTP id a21mr115659427pgv.98.1564891701728; Sat, 03 Aug 2019 21:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564891701; cv=none; d=google.com; s=arc-20160816; b=QCXxqXKgtyIlzqZHzRsOnnBmjAbk4gd+XflM0AnBAj96L0oFG9NgjhwR5KoD4q3/I7 Sql7Nqg4+rbqdk7Hm1PT9tNgK/287TnzUFH4+iYtq1mfIOI6fht1R8sPgO9a/7Q9FOzl e+Hg3oqWL1EA2tCOIyujt1oxCqjceyKhaH4TWU0vWuBsXrLAWWwyVt6xlCP/bV9y/12e nTHq3Ab2InvALjM/vg7J80oCcssuGaA3Z1biUqZWYHJTFn7fNgLDB4n9Hh0QhAj2cBfQ jUNTPCo2dm7vRaUzyIv5Z+VW65NBxu5yDibR56dNt8b2wp7sCkc2sqFn7MJqinQuj9de V2NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=//GfN3Tbw0iv5naNbxPygrhfLkS7hy9vXqEmA+ERuTo=; b=bYCQuiDPzTOmcNtTp9hR3pegmeazLM2Pr/RrmRZ/UNrnIfM5h5O+iBQHP8JgO5ECED p1cVWz3J6Gpm33QKIsZ62unZt0SV/WQM7Bhkd6Esw0aLKPBOVZMaEsf8J7n8IijbgDyc XzCKL/D0YUrOF2Mm9dKR1MqgCJvWl6lyhMNBm03Kqo1sq9Ytw8T3+G78Yq7a90+GAcNP ScGIhvpx/qB5jZ7LkabsKl/7dT+IKt6XVEf0pmYEwXL/yN9+uefBCJLSFR6OBEiApl9U NzEhEdVYADQrijgXt/HIxuKXnPjylC3x0KS4pKOFcbZHBlLwHVSs2ceMb6KlL6dWUen1 gaog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jWH0xTg/"; 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 a187si39859534pge.269.2019.08.03.21.08.06; Sat, 03 Aug 2019 21:08:21 -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="jWH0xTg/"; 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 S1729497AbfHDCsi (ORCPT + 99 others); Sat, 3 Aug 2019 22:48:38 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44383 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729465AbfHDCsi (ORCPT ); Sat, 3 Aug 2019 22:48:38 -0400 Received: by mail-pg1-f195.google.com with SMTP id i18so37951374pgl.11 for ; Sat, 03 Aug 2019 19:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=//GfN3Tbw0iv5naNbxPygrhfLkS7hy9vXqEmA+ERuTo=; b=jWH0xTg/65qp8vQiXDVhWNKmPIRchShll3kyPuLJ0T1HSLWmsqStAdcfAFEJbQGPJB TRbV2ehDZ1w+s4qtip8bQt32gi+URtuRkaRz79e/Epp4XCKc7GeL0axSdAwMauM7Mi7/ PoB5LboeDtzanpCpTIhVxGcN4BQUVfbpUMHPaixfaDFHUYXo4dR+WLHaM2J9Dww1bmwa wWKvH/FjMS4BgtzWiO7VlPlN9PcyadiRE7OpIj7jrIR3EbT5/VSfaZ42HLMk/jqDNvL6 o+Sp89FIyJoXr2NKo/W6NrAV9GA/VV7GdclMVFEajjekO25ZJJpXq12OKbaqYnF/aPbd SpJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=//GfN3Tbw0iv5naNbxPygrhfLkS7hy9vXqEmA+ERuTo=; b=Gl2HEzSE1KI7YLlXy984DVaOQDajWUmCeRalCrQ8CU+TXgMp07uYKuxsvW1+3qllrT aUsDj7TgWg7TN8mbqAGkWSTbNC4YZFYxnzqMkrSj2iUq5QDTxsmdYsL7nS96EXmNHcH6 oK1707qNw3uHVmwNz+bjkVeAvZ1e91IBcFKmUM0dnc3dOi1GuaXkb0nfSQYPGIDYk545 94a/9IJdS0azGV/Ro3QQuoqXiKtMebhBroLP64Bx48+my2dMxggi1jy4rLxIBpxfCvzI L7tfr7MbQTF/nR36Wrqm30/gKovkyYfbu5axWOk7clsObb+f/ocb2kVW+gC1hl8fC6XK YP+A== X-Gm-Message-State: APjAAAXrWY0Uc/23etUhZhJOsHF6ddKfrgfyiLrDPrPurJl00Zre0Muj jaqzby4cgOREGcjphSSTsT8= X-Received: by 2002:a17:90a:3aed:: with SMTP id b100mr11734655pjc.63.1564886917381; Sat, 03 Aug 2019 19:48:37 -0700 (PDT) Received: from hari-Inspiron-1545 ([183.83.86.126]) by smtp.gmail.com with ESMTPSA id u128sm90686772pfu.48.2019.08.03.19.48.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 19:48:36 -0700 (PDT) Date: Sun, 4 Aug 2019 08:18:32 +0530 From: Hariprasad Kelam To: joe@perches.com, Greg Kroah-Hartman , Himadri Pandya , Larry Finger , Hariprasad Kelam , Michiel Schuurmans , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [Patch v2] staging: rtl8192e: Make use kmemdup Message-ID: <20190804024832.GA14352@hari-Inspiron-1545> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As kmemdup API does kmalloc + memcpy . We can make use of it instead of calling kmalloc and memcpy independetly. Signed-off-by: Hariprasad Kelam --- v2 - remove the netdev_info() uses for allocation failures drivers/staging/rtl8192e/rtllib_softmac.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index e29e8d6..f2f7529 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1382,15 +1382,10 @@ rtllib_association_req(struct rtllib_network *beacon, ieee->assocreq_ies = NULL; ies = &(hdr->info_element[0].id); ieee->assocreq_ies_len = (skb->data + skb->len) - ies; - ieee->assocreq_ies = kmalloc(ieee->assocreq_ies_len, GFP_ATOMIC); - if (ieee->assocreq_ies) - memcpy(ieee->assocreq_ies, ies, ieee->assocreq_ies_len); - else { - netdev_info(ieee->dev, - "%s()Warning: can't alloc memory for assocreq_ies\n", - __func__); + ieee->assocreq_ies = kmemdup(ies, ieee->assocreq_ies_len, GFP_ATOMIC); + if (!ieee->assocreq_ies) ieee->assocreq_ies_len = 0; - } + return skb; } @@ -2259,17 +2254,12 @@ rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb, ieee->assocresp_ies = NULL; ies = &(assoc_resp->info_element[0].id); ieee->assocresp_ies_len = (skb->data + skb->len) - ies; - ieee->assocresp_ies = kmalloc(ieee->assocresp_ies_len, + ieee->assocresp_ies = kmemdup(ies, + ieee->assocresp_ies_len, GFP_ATOMIC); - if (ieee->assocresp_ies) - memcpy(ieee->assocresp_ies, ies, - ieee->assocresp_ies_len); - else { - netdev_info(ieee->dev, - "%s()Warning: can't alloc memory for assocresp_ies\n", - __func__); + if (!ieee->assocresp_ies) ieee->assocresp_ies_len = 0; - } + rtllib_associate_complete(ieee); } else { /* aid could not been allocated */ -- 2.7.4