From: Breno Leitao <leitao@debian.org>
To: Simon Horman <horms@kernel.org>
Cc: aleksander.lobakin@intel.com, kuba@kernel.org,
davem@davemloft.net, pabeni@redhat.com, edumazet@google.com,
Taras Chornyi <taras.chornyi@plvision.eu>,
quic_jjohnson@quicinc.com, kvalo@kernel.org, leon@kernel.org,
dennis.dalessandro@cornelisnetworks.com,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/5] net: marvell: prestera: allocate dummy net_device dynamically
Date: Wed, 3 Apr 2024 07:27:29 -0700 [thread overview]
Message-ID: <Zg1nUR0Xb8LgKE9f@gmail.com> (raw)
In-Reply-To: <20240331085438.GA26556@kernel.org>
On Sun, Mar 31, 2024 at 09:54:38AM +0100, Simon Horman wrote:
> On Thu, Mar 28, 2024 at 04:52:02PM -0700, Breno Leitao wrote:
> > Embedding net_device into structures prohibits the usage of flexible
> > arrays in the net_device structure. For more details, see the discussion
> > at [1].
> >
> > Un-embed the net_device from the private struct by converting it
> > into a pointer. Then use the leverage the new alloc_netdev_dummy()
> > helper to allocate and initialize dummy devices.
> >
> > [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
> >
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> > .../net/ethernet/marvell/prestera/prestera_rxtx.c | 15 ++++++++++++---
> > 1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c b/drivers/net/ethernet/marvell/prestera/prestera_rxtx.c
>
> ...
>
> > @@ -654,13 +654,21 @@ static int prestera_sdma_switch_init(struct prestera_switch *sw)
> > if (err)
> > goto err_evt_register;
> >
> > - init_dummy_netdev(&sdma->napi_dev);
> > + sdma->napi_dev = alloc_netdev_dummy(0);
> > + if (!sdma->napi_dev) {
> > + dev_err(dev, "not able to initialize dummy device\n");
> > + goto err_alloc_dummy;
>
> Hi Breno,
>
> This goto will result in the function returning err.
> But err is 0 here. Perhaps it should be set to a negative error value
> instead?
Definitely, that was a good catch.
> Flagged by Smatch.
I am curious how you are running Smatch. I tried to run it here
according to[1] , and I found different and valid errors also, that I
will fix soon. For instance:
drivers/net/ethernet/marvell/prestera/prestera_main.c:433 prestera_port_sfp_bind() error: uninitialized symbol 'err'.
drivers/net/ethernet/marvell/prestera/prestera_main.c:861 prestera_switch_set_base_mac_addr() error: uninitialized symbol 'ret'.
[1] https://rajanvaja.wordpress.com/2021/02/06/how-to-run-smatch-on-linux-kernel/
Thanks
next prev parent reply other threads:[~2024-04-03 14:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 23:52 [PATCH net-next v2 0/5] allocate dummy device dynamically Breno Leitao
2024-03-28 23:52 ` Breno Leitao
2024-03-28 23:52 ` [PATCH net-next v2 1/5] net: create a dummy net_device allocator Breno Leitao
2024-03-28 23:52 ` [PATCH net-next v2 2/5] net: marvell: prestera: allocate dummy net_device dynamically Breno Leitao
2024-03-29 15:56 ` Jakub Kicinski
2024-03-29 17:21 ` Breno Leitao
2024-03-31 8:54 ` Simon Horman
2024-04-03 14:27 ` Breno Leitao [this message]
2024-03-28 23:52 ` [PATCH net-next v2 3/5] net: mediatek: mtk_eth_sock: " Breno Leitao
2024-03-28 23:52 ` Breno Leitao
2024-03-28 23:52 ` [PATCH net-next v2 4/5] net: ipa: " Breno Leitao
2024-04-01 13:56 ` Alex Elder
2024-04-03 13:38 ` Breno Leitao
2024-03-28 23:52 ` [PATCH net-next v2 5/5] net: ibm/emac: " Breno Leitao
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=Zg1nUR0Xb8LgKE9f@gmail.com \
--to=leitao@debian.org \
--cc=aleksander.lobakin@intel.com \
--cc=davem@davemloft.net \
--cc=dennis.dalessandro@cornelisnetworks.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kvalo@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=quic_jjohnson@quicinc.com \
--cc=taras.chornyi@plvision.eu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.