From: Hariprasad Kelam <hariprasad.kelam@gmail.com>
To: Joe Perches <joe@perches.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Himadri Pandya <himadri18.07@gmail.com>,
Michiel Schuurmans <michielschuurmans@gmail.com>,
Larry Finger <Larry.Finger@lwfinger.net>,
Hariprasad Kelam <hariprasad.kelam@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8192e: Make use kmemdup
Date: Sun, 4 Aug 2019 08:08:44 +0530 [thread overview]
Message-ID: <20190804023844.GA14043@hari-Inspiron-1545> (raw)
In-Reply-To: <774ade692f5e64ab1f4fc7b35b9eeae69e11cf71.camel@perches.com>
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
prev parent reply other threads:[~2019-08-04 2:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-03 17:40 Hariprasad Kelam
2019-08-03 17:52 ` Joe Perches
2019-08-04 2:38 ` Hariprasad Kelam [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190804023844.GA14043@hari-Inspiron-1545 \
--to=hariprasad.kelam@gmail.com \
--cc=Larry.Finger@lwfinger.net \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=himadri18.07@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michielschuurmans@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®