On Tue, Apr 10, 2018 at 9:56 AM, Dave Jiang <dave.ji...@intel.com> wrote:
> When daxctl_unref is releasing the context, we should make sure that the
> regions and devices are also being released.
>
> Signed-off-by: Dave Jiang <dave.ji...@intel.com>
> ---
>  daxctl/lib/libdaxctl.c |    7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
> index 9e503201..0552f6d7 100644
> --- a/daxctl/lib/libdaxctl.c
> +++ b/daxctl/lib/libdaxctl.c
> @@ -119,11 +119,18 @@ DAXCTL_EXPORT struct daxctl_ctx *daxctl_ref(struct 
> daxctl_ctx *ctx)
>   */
>  DAXCTL_EXPORT void daxctl_unref(struct daxctl_ctx *ctx)
>  {
> +       struct daxctl_region *region;
> +
>         if (ctx == NULL)
>                 return;
>         ctx->refcount--;
>         if (ctx->refcount > 0)
>                 return;
> +
> +       while ((region = list_top(&ctx->regions, struct daxctl_region, list)) 
> !=
> +                       NULL)
> +               daxctl_region_unref(region);
> +

Sorry, should have mentioned this before. Why not use
list_for_each_entry_safe() to iterate and delete regions like all the
other free routines?
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to