Re: [net-next Patch v5 5/6] octeontx2-pf: Add support for HTB offload
From: Hariprasad Kelam
Date: Wed Mar 29 2023 - 12:44:48 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?
ACK, we can safely move this logic in device init.
Will add these changes in next version.
>
> > +
> > + 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.
ACK, will address this issue in next version.
Thanks,
Hariprasad k
>
> > + mutex_destroy(&pfvf->qos.qos_lock);
> > + return -ENOMEM;
> > + }
>
>
> [...]
>
> Cheers,
>
> Paolo