Re: [net-next Patch v5 5/6] octeontx2-pf: Add support for HTB offload

From: Paolo Abeni
Date: Tue Mar 28 2023 - 06:57:00 EST


On Sun, 2023-03-26 at 23:42 +0530, Hariprasad Kelam wrote:
[...]
> +static int otx2_qos_root_add(struct otx2_nic *pfvf, u16 htb_maj_id, u16 htb_defcls,
> + struct netlink_ext_ack *extack)
> +{
> + struct otx2_qos_cfg *new_cfg;
> + struct otx2_qos_node *root;
> + int err;
> +
> + netdev_dbg(pfvf->netdev,
> + "TC_HTB_CREATE: handle=0x%x defcls=0x%x\n",
> + htb_maj_id, htb_defcls);
> +
> + INIT_LIST_HEAD(&pfvf->qos.qos_tree);
> + mutex_init(&pfvf->qos.qos_lock);

It's quite strange and error prone dynamically init this mutex and the
list here. Why don't you do such init ad device creation time?

> +
> + root = otx2_qos_alloc_root(pfvf);
> + if (IS_ERR(root)) {
> + mutex_destroy(&pfvf->qos.qos_lock);
> + err = PTR_ERR(root);
> + return err;
> + }
> +
> + /* allocate txschq queue */
> + new_cfg = kzalloc(sizeof(*new_cfg), GFP_KERNEL);
> + if (!new_cfg) {
> + NL_SET_ERR_MSG_MOD(extack, "Memory allocation error");

Here the root node is leaked.

> + mutex_destroy(&pfvf->qos.qos_lock);
> + return -ENOMEM;
> + }


[...]

Cheers,

Paolo