[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<CH0PR18MB4339400F88392B69B8191ADBCDD42@CH0PR18MB4339.namprd18.prod.outlook.com>
Date: Mon, 24 Jun 2024 08:49:20 +0000
From: Geethasowjanya Akula <gakula@...vell.com>
To: Simon Horman <horms@...nel.org>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kuba@...nel.org" <kuba@...nel.org>,
"davem@...emloft.net"
<davem@...emloft.net>,
"pabeni@...hat.com" <pabeni@...hat.com>,
"edumazet@...gle.com" <edumazet@...gle.com>,
Sunil Kovvuri Goutham
<sgoutham@...vell.com>,
Subbaraya Sundeep Bhatta <sbhatta@...vell.com>,
Hariprasad Kelam <hkelam@...vell.com>
Subject: Re: [net-next PATCH v5 03/10] octeontx2-pf: Create representor netdev
>-----Original Message-----
>From: Simon Horman <horms@...nel.org>
>Sent: Tuesday, June 18, 2024 1:55 PM
>To: Geethasowjanya Akula <gakula@...vell.com>
>Cc: netdev@...r.kernel.org; linux-kernel@...r.kernel.org; kuba@...nel.org;
>davem@...emloft.net; pabeni@...hat.com; edumazet@...gle.com; Sunil
>Kovvuri Goutham <sgoutham@...vell.com>; Subbaraya Sundeep Bhatta
><sbhatta@...vell.com>; Hariprasad Kelam <hkelam@...vell.com>
>Subject: [EXTERNAL] Re: [net-next PATCH v5 03/10] octeontx2-pf: Create
>representor netdev
>
>On Tue, Jun 11, 2024 at 09:52: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@...vell.com>
>
>...
>
>> +void rvu_rep_destroy(struct otx2_nic *priv) {
>> + struct rep_dev *rep;
>> + int rep_id;
>> +
>> + rvu_rep_free_cq_rsrc(priv);
>> + for (rep_id = 0; rep_id < priv->rep_cnt; rep_id++) {
>> + rep = priv->reps[rep_id];
>> + unregister_netdev(rep->netdev);
>> + free_netdev(rep->netdev);
>> + }
>> + kfree(priv->reps);
>> +}
>> +
>> +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 = kcalloc(rep_cnt, sizeof(struct rep_dev *), GFP_KERNEL);
>> + 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",
>> + 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");
>
>Hi Geetha,
>
>(The most recently allocated) ndev appears to be leaked here.
>
>I think that one way to address this could be to moving the contents of this
>loop into a separate function that unwinds the most recent allocation on error.
>
>Highlighted by Smatch (although it seems a bit confused here).
>
> .../rep.c:184 rvu_rep_create() warn: 'ndev' from alloc_etherdev_mqs() not
>released on lines: 184.
> .../rep.c:184 rvu_rep_create() warn: 'ndev' from register_netdev() not
>released on lines: 184.
>
>Sorry for not bringing this up earlier: it is at least the third time I have looked
>over this, and for some reason I didn't notice this the other times.
>
Ok will recheck and fix the issue in next version.
>> + goto exit;
>> + }
>> + }
>> + err = rvu_rep_napi_init(priv, extack);
>> + if (err)
>> + goto exit;
>> +
>> + return 0;
>> +exit:
>> + while (--rep_id >= 0) {
>> + rep = priv->reps[rep_id];
>> + unregister_netdev(rep->netdev);
>> + free_netdev(rep->netdev);
>> + }
>> + kfree(priv->reps);
>> + return err;
>> +}
>> +
>> static int rvu_rep_rsrc_free(struct otx2_nic *priv) {
>> struct otx2_qset *qset = &priv->qset;
>
>...
Powered by blists - more mailing lists