Re: [PATCH V4 for-next 02/10] IB/core: Introduce Work Queue object and its verbs

Or Gerlitz
2016-05-30T20:09:54Z

On Mon, May 23, 2016 at 3:20 PM, Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:

> +int ib_destroy_wq(struct ib_wq *wq)
> +{
> + int err;
> + struct ib_cq *cq = wq->cq;
> + struct ib_pd *pd = wq->pd;
> +
> + if (atomic_read(&wq->usecnt))
> + return -EBUSY;
> +
> + err = wq->device->destroy_wq(wq);
> + if (!err) {
> + atomic_dec(&pd->usecnt);
> + atomic_dec(&cq->usecnt);
> + }
> + return err;

by the reverse unwinding principle

> + atomic_inc(&pd->usecnt);
> + atomic_inc(&wq_attr->cq->usecnt);

-->

> + atomic_dec(&cq->usecnt);
> + atomic_dec(&pd->usecnt);