From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
antoine.tenart@bootlin.com, thomas.petazzoni@bootlin.com,
gregory.clement@bootlin.com, miquel.raynal@bootlin.com,
nadavh@marvell.com, stefanc@marvell.com, ymarkman@marvell.com,
mw@semihalf.com
Subject: Re: [PATCH net-next v2] net: mvpp2: Don't use dynamic allocs for local variables
Date: Thu, 22 Mar 2018 20:14:53 +0100 [thread overview]
Message-ID: <20180322201453.706b0ab8@bootlin.com> (raw)
In-Reply-To: <20180322.144709.550558706036978967.davem@davemloft.net>
Hello David,
On Thu, 22 Mar 2018 14:47:09 -0400 (EDT),
David Miller <davem@davemloft.net> wrote :
> From: Maxime Chevallier <maxime.chevallier@bootlin.com>
> Date: Wed, 21 Mar 2018 16:14:00 +0100
>
> > diff --git a/drivers/net/ethernet/marvell/mvpp2.c
> > b/drivers/net/ethernet/marvell/mvpp2.c index
> > 9bd35f2291d6..28e33e139178 100644 ---
> > a/drivers/net/ethernet/marvell/mvpp2.c +++
> > b/drivers/net/ethernet/marvell/mvpp2.c @@ -1913,16 +1913,11 @@
> > static void mvpp2_prs_sram_offset_set(struct mvpp2_prs_entry *pe, }
> >
> > /* Find parser flow entry */
> > -static struct mvpp2_prs_entry *mvpp2_prs_flow_find(struct mvpp2
> > *priv, int flow) +static int mvpp2_prs_flow_find(struct mvpp2
> > *priv, int flow) {
> > - struct mvpp2_prs_entry *pe;
> > + struct mvpp2_prs_entry pe;
> > int tid;
> >
> > - pe = kzalloc(sizeof(*pe), GFP_KERNEL);
> > - if (!pe)
> > - return NULL;
> > - mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_FLOWS);
> > -
>
> In order to be an equivalent change you must bzero out this 'pe'
> object on the stack. You are only initializing the index member
> before passing it into other functions.
I agree that this is unclear, but the functions I pass these objects to
only need the index field to be set, and will fill the rest of the
object according to the underlying HW representation (these objects
mirror the HW configuration).
I can see that this is confusing, we might want to make the
mvpp2_prs_hw_read function more explicit about this.
Would comments explaning this be enough, or should I try another way to
make this cleaner ?
Thanks,
Maxime
next prev parent reply other threads:[~2018-03-22 19:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 15:14 [PATCH net-next v2] net: mvpp2: Don't use dynamic allocs for local variables Maxime Chevallier
2018-03-21 19:57 ` Yan Markman
2018-03-21 21:14 ` Maxime Chevallier
2018-03-22 18:47 ` David Miller
2018-03-22 19:14 ` Maxime Chevallier [this message]
2018-03-22 19:43 ` David Miller
2018-03-22 19:53 ` Maxime Chevallier
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=20180322201453.706b0ab8@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=antoine.tenart@bootlin.com \
--cc=davem@davemloft.net \
--cc=gregory.clement@bootlin.com \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=mw@semihalf.com \
--cc=nadavh@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=stefanc@marvell.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=ymarkman@marvell.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;
as well as URLs for NNTP newsgroup(s).