linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: hariprasad@chelsio.com, Ganesh Goudar <ganeshgr@chelsio.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [bug report] RDMA/iw_cxgb4: Low resource fixes for Completion queue
Date: Sun, 22 Oct 2023 10:51:38 +0300	[thread overview]
Message-ID: <20231022075138.GA10551@unreal> (raw)
In-Reply-To: <73451d77-8612-4e14-9695-ad455b84f673@moroto.mountain>

On Fri, Oct 20, 2023 at 06:45:19PM +0300, Dan Carpenter wrote:
> Hello,
> 
> The patch dd6b0241260d: "RDMA/iw_cxgb4: Low resource fixes for
> Completion queue" from Jun 10, 2016 (linux-next), leads to the
> following Smatch static checker warning:
> 
> 	drivers/infiniband/hw/cxgb4/cq.c:1153 c4iw_create_cq()
> 	error: double free of 'chp->destroy_skb'
> 
> drivers/infiniband/hw/cxgb4/cq.c
>     1138         pr_debug("cqid 0x%0x chp %p size %u memsize %zu, dma_addr %pad\n",
>     1139                  chp->cq.cqid, chp, chp->cq.size, chp->cq.memsize,
>     1140                  &chp->cq.dma_addr);
>     1141         return 0;
>     1142 err_free_mm2:
>     1143         kfree(mm2);
>     1144 err_free_mm:
>     1145         kfree(mm);
>     1146 err_remove_handle:
>     1147         xa_erase_irq(&rhp->cqs, chp->cq.cqid);
>     1148 err_destroy_cq:
>     1149         destroy_cq(&chp->rhp->rdev, &chp->cq,
>     1150                    ucontext ? &ucontext->uctx : &rhp->rdev.uctx,
>     1151                    chp->destroy_skb, chp->wr_waitp);
> 
> destroy_cq() calls kfree_skb(chp->destroy_skb).  The call tree is:
> 
> destroy_cq()
> -> c4iw_ref_send_wait()
>    -> c4iw_ofld_send()
>       -> kfree_skb()

It is not always the case, kfree_skb() is called in c4iw_ofld_send() error flows only.

> 
>     1152 err_free_skb:
> --> 1153         kfree_skb(chp->destroy_skb);
> 
> Probably we can just delete this kfree_skb()?

I don't think so, in case create_cq() failed, there is a need to clean
preallocated SKB.

Thanks

> 
>     1154 err_free_wr_wait:
>     1155         c4iw_put_wr_wait(chp->wr_waitp);
>     1156 err_free_chp:
>     1157         return ret;
>     1158 }
> 
> regards,
> dan carpenter

      reply	other threads:[~2023-10-22  7:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-20 15:45 [bug report] RDMA/iw_cxgb4: Low resource fixes for Completion queue Dan Carpenter
2023-10-22  7:51 ` Leon Romanovsky [this message]

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=20231022075138.GA10551@unreal \
    --to=leon@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=ganeshgr@chelsio.com \
    --cc=hariprasad@chelsio.com \
    --cc=linux-rdma@vger.kernel.org \
    /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).