Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe()

2023-06-02 Thread Dan Williams
Paul Cassella wrote: > On Fri, 2 Jun 2023, Ira Weiny wrote: > > Paul Cassella wrote: > > > On Sat, 3 Dec 2022, Ira Weiny wrote: > > > > On Sat, Dec 03, 2022 at 09:58:58AM +, Yongqiang Liu wrote: > > > > > > We should always call dax_region_put() whenever devm_create_dev_dax() > > > > > succeed

[PATCH RFC 4/4] dax/bus: Remove unnecessary reference in alloc_dax_region()

2023-06-02 Thread Ira Weiny
All the callers to alloc_dax_region() maintain the device associated with the dax_region until the dax_region is referenced by the dax_dev they are creating. Remove the extra kref that alloc_dax_region() takes. Add a comment to clarify the reference counting should additional callers be grown lat

[PATCH RFC 3/4] dax/cxl: Fix refcount leak in cxl_dax_region_probe()

2023-06-02 Thread Ira Weiny
alloc_dax_region() returns a reference protected dax_region. Regardless of the success of the devm_create_dev_dax() the reference returned from alloc_dax_region() needs to be released. Drop the dax_region reference regardless of the success of dev_dax creation. Clean up comments. Fixes: 09d09e0

[PATCH RFC 1/4] dax/bus: Fix leaked reference in alloc_dax_region()

2023-06-02 Thread Ira Weiny
kref_init() initializes the ref count to 1. An extra kref is taken on the dax_region to be used by the caller. If devm_add_action_or_reset() fails this extra reference is leaked. Drop the extra reference on error. Fixes: d7fe1a67f658 ("dax: add region 'id', 'size', and 'align' attributes") Cc:

[PATCH RFC 2/4] dax/hmem: Fix refcount leak in dax_hmem_probe()

2023-06-02 Thread ira . weiny
From: Yongqiang Liu We should always call dax_region_put() whenever devm_create_dev_dax() succeed or fail to avoid refcount leak of dax_region. Move the return value check after dax_region_put(). Cc: nvd...@lists.linux.dev Fixes: c01044cc8191 ("ACPI: HMAT: refactor hmat_register_target_device to

[PATCH RFC 0/4] dax: Clean up dax_region references

2023-06-02 Thread Ira Weiny
8967acc1d9 change-id: 20230602-dax-region-put-72c289137cb1 Best regards, -- Ira Weiny

Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe()

2023-06-02 Thread Ira Weiny
Paul Cassella wrote: > On Fri, 2 Jun 2023, Ira Weiny wrote: > > Paul Cassella wrote: > > > On Sat, 3 Dec 2022, Ira Weiny wrote: > > > > On Sat, Dec 03, 2022 at 09:58:58AM +, Yongqiang Liu wrote: > > > > > > We should always call dax_region_put() whenever devm_create_dev_dax() > > > > > succeed

Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe()

2023-06-02 Thread Paul Cassella
On Fri, 2 Jun 2023, Ira Weiny wrote: > Paul Cassella wrote: > > On Sat, 3 Dec 2022, Ira Weiny wrote: > > > On Sat, Dec 03, 2022 at 09:58:58AM +, Yongqiang Liu wrote: > > > > We should always call dax_region_put() whenever devm_create_dev_dax() > > > > succeed or fail to avoid refcount leak of

Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe()

2023-06-02 Thread Ira Weiny
Paul Cassella wrote: > On Sat, 3 Dec 2022, Ira Weiny wrote: > > On Sat, Dec 03, 2022 at 09:58:58AM +, Yongqiang Liu wrote: > > > > We should always call dax_region_put() whenever devm_create_dev_dax() > > > succeed or fail to avoid refcount leak of dax_region. Move the return > > > value check