From: Breno Leitao <leitao@debian.org>
To: Jakub Kicinski <kuba@kernel.org>
Cc: horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com,
linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
horms@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 3/4] crypto: caam: Unembed net_dev structure from qi
Date: Thu, 4 Jul 2024 09:15:29 -0700 [thread overview]
Message-ID: <ZobKod5Fhf1kvLp1@gmail.com> (raw)
In-Reply-To: <20240703194533.5a00ea5d@kernel.org>
Hello Jakub,
On Wed, Jul 03, 2024 at 07:45:33PM -0700, Jakub Kicinski wrote:
> On Tue, 2 Jul 2024 11:55:53 -0700 Breno Leitao wrote:
> > @@ -751,10 +766,16 @@ int caam_qi_init(struct platform_device *caam_pdev)
> > struct caam_qi_pcpu_priv *priv = per_cpu_ptr(&pcpu_qipriv, i);
> > struct caam_napi *caam_napi = &priv->caam_napi;
> > struct napi_struct *irqtask = &caam_napi->irqtask;
> > - struct net_device *net_dev = &priv->net_dev;
> > + struct net_device *net_dev;
> >
> > + net_dev = alloc_netdev_dummy(0);
> > + if (!net_dev) {
> > + err = -ENOMEM;
> > + goto fail;
>
> free_netdev() doesn't take NULL, free_caam_qi_pcpu_netdev()
> will feed it one if we fail here
Sorry, I am not sure I followed you. Let me ask a clarifying questions:
Do you think that free_netdev() will take NULL ?
If that is the case, that *shouldn't* happen, since I have a cpumask
that tracks the percpu netdev that got allocated, and only free those
percpu-net_device that was properly allocated.
Let me simplify the code to make it easy to understand what I had in
mind:
int caam_qi_init(struct platform_device *caam_pdev) {
cpumask_clear(&clean_mask);
net_dev = alloc_netdev_dummy(0);
if (!net_dev)
goto fail;
cpumask_set_cpu(i, &clean_mask);
fail:
free_caam_qi_pcpu_netdev(&clean_mask);
}
static void free_caam_qi_pcpu_netdev(const cpumask_t *cpus) {
for_each_cpu(i, cpus) {
priv = per_cpu_ptr(&pcpu_qipriv, i);
free_netdev(priv->net_dev);
}
}
So, if alloc_netdev_dummy() fails, then the cpu current cpu will not be
set in `clean_mask`, thus, free_caam_qi_pcpu_netdev() will not free it
later.
Anyway, let me know if I am missing something.
next prev parent reply other threads:[~2024-07-04 16:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 18:55 [PATCH net-next v3 0/3] crypto: caam: Unembed net_dev Breno Leitao
2024-07-02 18:55 ` [PATCH net-next v3 1/4] crypto: caam: Avoid unused imx8m_machine_match variable Breno Leitao
2024-07-05 10:11 ` Horia Geanta
2024-07-08 11:29 ` Breno Leitao
2024-07-09 10:44 ` Horia Geanta
2024-07-02 18:55 ` [PATCH net-next v3 2/4] crypto: caam: Make CRYPTO_DEV_FSL_CAAM dependent of COMPILE_TEST Breno Leitao
2024-07-02 18:55 ` [PATCH net-next v3 3/4] crypto: caam: Unembed net_dev structure from qi Breno Leitao
2024-07-04 2:45 ` Jakub Kicinski
2024-07-04 16:15 ` Breno Leitao [this message]
2024-07-04 17:18 ` Jakub Kicinski
2024-07-02 18:55 ` [PATCH net-next v3 4/4] crypto: caam: Unembed net_dev structure in dpaa2 Breno Leitao
2024-07-03 5:45 ` [EXT] " Gaurav Jain
2024-07-03 11:26 ` Breno Leitao
2024-07-04 18:00 ` [PATCH net-next v3 0/3] crypto: caam: Unembed net_dev patchwork-bot+netdevbpf
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=ZobKod5Fhf1kvLp1@gmail.com \
--to=leitao@debian.org \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=herbert@gondor.apana.org.au \
--cc=horia.geanta@nxp.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pankaj.gupta@nxp.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).