From: Simon Horman <horms@kernel.org>
To: Geetha sowjanya <gakula@marvell.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com,
edumazet@google.com, sgoutham@marvell.com, sbhatta@marvell.com,
hkelam@marvell.com, Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [net-next PATCH v3 3/9] octeontx2-pf: Create representor netdev
Date: Wed, 1 May 2024 19:06:56 +0100 [thread overview]
Message-ID: <20240501180656.GX2575892@kernel.org> (raw)
In-Reply-To: <20240428105312.9731-4-gakula@marvell.com>
+ Dan Carpenter
On Sun, Apr 28, 2024 at 04:23:06PM +0530, Geetha sowjanya wrote:
> Adds initial devlink support to set/get the switchdev mode.
> Representor netdevs are created for each rvu devices when
> the switch mode is set to 'switchdev'. These netdevs are
> be used to control and configure VFs.
>
> Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Hi Geetha,
Some minor feedback from my side.
...
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
...
> +int rvu_rep_create(struct otx2_nic *priv, struct netlink_ext_ack *extack)
> +{
> + int rep_cnt = priv->rep_cnt;
> + struct net_device *ndev;
> + struct rep_dev *rep;
> + int rep_id, err;
> + u16 pcifunc;
> +
> + priv->reps = devm_kcalloc(priv->dev, rep_cnt, sizeof(struct rep_dev), GFP_KERNEL);
It looks like the size argument should be sizeof(struct rep_dev *)
or sizeof(*priv->reps).
Flagged by Coccinelle.
Please consider limiting lines in Networking code to 80 columns wide
where it can be achieved without too much bother.
> + if (!priv->reps)
> + return -ENOMEM;
> +
> + for (rep_id = 0; rep_id < rep_cnt; rep_id++) {
> + ndev = alloc_etherdev(sizeof(*rep));
> + if (!ndev) {
> + NL_SET_ERR_MSG_FMT_MOD(extack, "PFVF representor:%d creation failed\n",
> + rep_id);
> + err = -ENOMEM;
> + goto exit;
> + }
> +
> + rep = netdev_priv(ndev);
> + priv->reps[rep_id] = rep;
> + rep->mdev = priv;
> + rep->netdev = ndev;
> + rep->rep_id = rep_id;
> +
> + ndev->min_mtu = OTX2_MIN_MTU;
> + ndev->max_mtu = priv->hw.max_mtu;
> + pcifunc = priv->rep_pf_map[rep_id];
> + rep->pcifunc = pcifunc;
> +
> + snprintf(ndev->name, sizeof(ndev->name), "r%dp%d", rep_id,
> + rvu_get_pf(pcifunc));
> +
> + eth_hw_addr_random(ndev);
> + err = register_netdev(ndev);
> + if (err) {
> + NL_SET_ERR_MSG_MOD(extack, "PFVF reprentator registration failed\n");
I don't think the string passed to NL_SET_ERR_MSG_MOD needs a trailing '\n'.
I'm unsure if this also applies to NL_SET_ERR_MSG_FMT_MOD or not.
Flagged by Coccinelle.
The current ndev appears to be leaked here,
as it does not appear to be covered by the unwind loop below.
I think this can be resolved using:
free_netdev(ndev);
> + goto exit;
> + }
> + }
> + err = rvu_rep_napi_init(priv, extack);
> + if (err)
> + goto exit;
Even with the above fixed, Smatch complains that:
.../rep.c:180 rvu_rep_create() warn: 'ndev' from alloc_etherdev_mqs() not released on lines: 180.
.../rep.c:180 rvu_rep_create() warn: 'ndev' from register_netdev() not released on lines: 180.
Where line 180 is the very last line of the funciton: return err;
I think this is triggered by the error handling above.
However, I also think it is a false positive.
I've CCed Dan Carpenter as I'd value a second opinion on this one.
> +
> + return 0;
> +exit:
> + while (--rep_id >= 0) {
> + rep = priv->reps[rep_id];
> + unregister_netdev(rep->netdev);
> + free_netdev(rep->netdev);
> + }
> + return err;
> +}
...
next prev parent reply other threads:[~2024-05-01 18:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 10:53 [net-next PATCH v3 0/9] Introduce RVU representors Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 1/9] octeontx2-pf: Refactoring RVU driver Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 2/9] octeontx2-pf: RVU representor driver Geetha sowjanya
2024-05-01 16:06 ` Simon Horman
2024-04-28 10:53 ` [net-next PATCH v3 3/9] octeontx2-pf: Create representor netdev Geetha sowjanya
2024-04-29 11:33 ` Jiri Pirko
2024-04-29 16:13 ` [EXTERNAL] " Geethasowjanya Akula
2024-04-30 6:57 ` Jiri Pirko
2024-04-30 15:17 ` Geethasowjanya Akula
2024-05-01 18:06 ` Simon Horman [this message]
2024-05-02 7:01 ` Dan Carpenter
2024-05-03 6:27 ` [EXTERNAL] " Geethasowjanya Akula
2024-05-01 18:18 ` Simon Horman
2024-04-28 10:53 ` [net-next PATCH v3 4/9] octeontx2-pf: Add basic net_device_ops Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 5/9] octeontx2-af: Add packet path between representor and VF Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 6/9] octeontx2-pf: Get VF stats via representor Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 7/9] octeontx2-pf: Add support to sync link state between representor and VFs Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 8/9] octeontx2-pf: Configure VF mtu via representor Geetha sowjanya
2024-04-28 10:53 ` [net-next PATCH v3 9/9] octeontx2-pf: Add representors for sdp MAC Geetha sowjanya
2024-04-29 11:31 ` [net-next PATCH v3 0/9] Introduce RVU representors Jiri Pirko
2024-04-29 13:51 ` [EXTERNAL] " Geethasowjanya Akula
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=20240501180656.GX2575892@kernel.org \
--to=horms@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@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).