Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1228276ybh; Sat, 3 Aug 2019 21:07:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDz/kOcNkTmQcSHZzPyg3asdrkbbIb3dzNiGOLrm6DeJT453An4jlkuJNIxKrngpA3KXuY X-Received: by 2002:a17:90a:1c1:: with SMTP id 1mr12003404pjd.72.1564891629504; Sat, 03 Aug 2019 21:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564891629; cv=none; d=google.com; s=arc-20160816; b=sDd3xDNVL5DDMgM/GW7mfVlZhlEUX9jqz42BnMqkD0V0S1nGkaQMWF4aBF8iImoiCG r2IIwtioulJEMkTZFllHUL5gXNuzSv7IqBryuNEElbSnyHSKtn2X60NBZ/63O6NlAzAx cPOYRaOvrT1qCUbUGR0GcitQheVgIArs1XOj+BZzrzNEaZN1oDaIm4ixwj1QCJBL+T+I C6ghGl5CilFR3XcMwQLrYchhgaVcgqYRGgUhnTsUalq+DBWLM1oTIWeqC8HZSvlE55c1 NCo5lCHnRYGmBKKgT5mqaMjetzxLzLyrn86K/G9B4+rM5e2Xx+oM1PvfOxSvBSEBw2s0 eVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=H2kGdFHGIeclWVr2UklHiFu8m0yV1tr6Ja1uSrC9yrU=; b=MHlmlSoRCvCLFvwwnC+MTVpdY3YyAqlKbCiQ6vHp1WBENLp8s9RogtXtYA+hg5Fq0W YHgMxVwH+e1f3eL1/oPBvBfBUBENJdCZNyTPvLH+ppgW39LsdM9+sKQJ8Q1k1gCfBEw7 gOc7RigV/BviEYLopeEAVSvi4M+Wk6Y0XKpTRNGt8mLi42ZtlgM/JCBN4nW53xh5lEpd eqC6j3NHhuLYOo/yJ1XxPUdKbhg2O0yWXLVv8qdHHQE7FzT4+He6GYb+JG7pKrgyOP2e Rh+EGEckOYBe1bA8qtZ6f/Obot0zv760HyvDwfxl0Hy2lZk9y1RtLQkog9rGDYpwhdVJ 50zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tP3qwu4p; 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 a15si45480160pfg.87.2019.08.03.21.06.54; Sat, 03 Aug 2019 21:07:09 -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=tP3qwu4p; 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 S1729485AbfHDCiv (ORCPT + 99 others); Sat, 3 Aug 2019 22:38:51 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33205 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729473AbfHDCiu (ORCPT ); Sat, 3 Aug 2019 22:38:50 -0400 Received: by mail-pl1-f196.google.com with SMTP id c14so35031360plo.0 for ; Sat, 03 Aug 2019 19:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=H2kGdFHGIeclWVr2UklHiFu8m0yV1tr6Ja1uSrC9yrU=; b=tP3qwu4p8GBWE8MXvyloMEeMxNcfG9oqiL/iohCbp15o7RI7C6M3uxeOcDRICZqIMl D6xpXXir3LaQxGqAReCLckgjEbmPhIKBCGmsKGgmOppzCeBu04+zmWaVEBTpt5biT++o tNxAS+vC76t+2kCphwNFHOAKjqcQ4sk32yvAU91Yjrc94wj3395xmxr6+Z2fmCutonM+ Wx3JuG9PRGI7szP0m14/jfDrx33N3ZpoJAG7GiKwEftlEC3SIvcJUEqHhLT1o5nOMcnX r+93WWtX7Yix0ZdwLUb0emMD7lRnJzJHHF6A2mFYaGZtDo+yRCHbkmb+xV+Zswg74eLr EtoQ== 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=H2kGdFHGIeclWVr2UklHiFu8m0yV1tr6Ja1uSrC9yrU=; b=ROPx383loFOto/K2lm04Ld89geGXUz4cnS8Yi9OvfeWopOy4DisqIZ1sebIUKgwBFE 7f5Oj1xGj+gviaZWidG3B23RqeqNIOsA/iP2kcO8jrY/NxKXzuHSSP3buiBDBAYun9OY tGoJy9YnLCgFcBjPbFw12zfcx/JiLxoLhCsdUKsAifQL4fxn11NGrBxqFCyJ+de2QWXB A2ZHVYE33IVZuTeM4dJ9apmtUdET1Rt3M1gqFaQht5Ik5IUDFlU7kXoV0CWdLe0/PiDM pJl3Lt9dzk86qH0oilTivrlhklHyvx0kgsLuebTMXKD8JUMLr+BHOmmF2Rr/heo7Kvmm xfJw== X-Gm-Message-State: APjAAAVBQJ3DRRtGr81UXE1+EUksbKTprVNi0fr7KjLTKJvmarIFe/j4 +l5rMM36OEgdz60d8lFfbIk= X-Received: by 2002:a17:902:86:: with SMTP id a6mr51950683pla.244.1564886330246; Sat, 03 Aug 2019 19:38:50 -0700 (PDT) Received: from hari-Inspiron-1545 ([183.83.86.126]) by smtp.gmail.com with ESMTPSA id v13sm92909934pfe.105.2019.08.03.19.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Aug 2019 19:38:49 -0700 (PDT) Date: Sun, 4 Aug 2019 08:08:44 +0530 From: Hariprasad Kelam To: Joe Perches , Greg Kroah-Hartman , Himadri Pandya , Michiel Schuurmans , Larry Finger , Hariprasad Kelam , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: rtl8192e: Make use kmemdup Message-ID: <20190804023844.GA14043@hari-Inspiron-1545> References: <20190803174038.GA10454@hari-Inspiron-1545> <774ade692f5e64ab1f4fc7b35b9eeae69e11cf71.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <774ade692f5e64ab1f4fc7b35b9eeae69e11cf71.camel@perches.com> 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 On Sat, Aug 03, 2019 at 10:52:04AM -0700, Joe Perches wrote: > On Sat, 2019-08-03 at 23:10 +0530, Hariprasad Kelam wrote: > > As kmemdup API does kmalloc + memcpy . We can make use of it instead of > > calling kmalloc and memcpy independetly. > [] > > diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c > [] > > @@ -1382,10 +1382,8 @@ 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 { > > + ieee->assocreq_ies = kmemdup(ies, ieee->assocreq_ies_len, GFP_ATOMIC); > > + if (!ieee->assocreq_ies) { > > netdev_info(ieee->dev, > > "%s()Warning: can't alloc memory for assocreq_ies\n", > > __func__); > > @@ -2259,12 +2257,10 @@ 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 { > > + if (!ieee->assocresp_ies) { > > netdev_info(ieee->dev, > > "%s()Warning: can't alloc memory for assocresp_ies\n", > > __func__); > > Could also remove the netdev_info() uses for allocation failures. > These are redundant as a dump_stack() is already done when OOM. > Sure will do. Thanks, Hariprasad k