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

From: Simon Horman
Date: Mon Apr 10 2023 - 09:28:20 EST


On Mon, Apr 10, 2023 at 02:12:22PM +0530, Hariprasad Kelam wrote:
> From: Naveen Mamindlapalli <naveenm@xxxxxxxxxxx>
>
> This patch registers callbacks to support HTB offload.
>
> Below are features supported,
>
> - supports traffic shaping on the given class by honoring rate and ceil
> configuration.
>
> - supports traffic scheduling, which prioritizes different types of
> traffic based on strict priority values.
>
> - supports the creation of leaf to inner classes such that parent node
> rate limits apply to all child nodes.
>
> Signed-off-by: Naveen Mamindlapalli <naveenm@xxxxxxxxxxx>
> Signed-off-by: Hariprasad Kelam <hkelam@xxxxxxxxxxx>
> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@xxxxxxxxxxx>
> Reviewed-by: Simon Horman <simon.horman@xxxxxxxxxxxx>

...

> +static int otx2_qos_txschq_alloc(struct otx2_nic *pfvf,
> + struct otx2_qos_cfg *cfg)
> +{
> + struct nix_txsch_alloc_req *req;
> + struct nix_txsch_alloc_rsp *rsp;
> + struct mbox *mbox = &pfvf->mbox;
> + int lvl, rc, schq;
> +
> + mutex_lock(&mbox->lock);
> + req = otx2_mbox_alloc_msg_nix_txsch_alloc(&pfvf->mbox);
> + if (!req) {
> + mutex_unlock(&mbox->lock);
> + return -ENOMEM;
> + }
> +
> + for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
> + req->schq[lvl] = cfg->schq[lvl];
> + req->schq_contig[lvl] = cfg->schq_contig[lvl];
> + }
> +
> + rc = otx2_sync_mbox_msg(&pfvf->mbox);
> + if (rc) {
> + mutex_unlock(&mbox->lock);
> + return rc;
> + }
> +
> + rsp = (struct nix_txsch_alloc_rsp *)
> + otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);

I think you need to check if otx2_mbox_get_rsp returned an error here.

Smatch reported this as:

drivers/net/ethernet/marvell/octeontx2/nic/qos.c:719 otx2_qos_txschq_alloc() error: 'rsp' dereferencing possible ERR_PTR()


> +
> + for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
> + for (schq = 0; schq < rsp->schq_contig[lvl]; schq++) {
> + cfg->schq_contig_list[lvl][schq] =
> + rsp->schq_contig_list[lvl][schq];
> + }
> + }