All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] device-dax: fix mismatches of request_mem_region()
@ 2020-08-17  6:59 Zhen Lei
  2020-08-17 18:57 ` Ira Weiny
  0 siblings, 1 reply; 3+ messages in thread
From: Zhen Lei @ 2020-08-17  6:59 UTC (permalink / raw)
  To: Dan Williams, Vishal Verma, Dave Jiang, Andrew Morton, linux-nvdimm
  Cc: Zhen Lei

The resources allocated by request_mem_region() is better to use
release_mem_region() to free. These two functions are paired.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 drivers/dax/kmem.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index 275aa5f873991af..9e38f9c2b6d7f02 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -82,8 +82,7 @@ int dev_dax_kmem_probe(struct device *dev)
 	rc = add_memory_driver_managed(numa_node, new_res->start,
 				       resource_size(new_res), kmem_name);
 	if (rc) {
-		release_resource(new_res);
-		kfree(new_res);
+		release_mem_region(kmem_start, kmem_size);
 		kfree(new_res_name);
 		return rc;
 	}
@@ -118,8 +117,7 @@ static int dev_dax_kmem_remove(struct device *dev)
 	}
 
 	/* Release and free dax resources */
-	release_resource(res);
-	kfree(res);
+	release_mem_region(kmem_start, kmem_size);
 	kfree(res_name);
 	dev_dax->dax_kmem_res = NULL;
 
-- 
1.8.3

_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] device-dax: fix mismatches of request_mem_region()
  2020-08-17  6:59 [PATCH 1/1] device-dax: fix mismatches of request_mem_region() Zhen Lei
@ 2020-08-17 18:57 ` Ira Weiny
  2020-08-18  2:20   ` Leizhen (ThunderTown)
  0 siblings, 1 reply; 3+ messages in thread
From: Ira Weiny @ 2020-08-17 18:57 UTC (permalink / raw)
  To: Zhen Lei; +Cc: Andrew Morton, linux-nvdimm

On Mon, Aug 17, 2020 at 02:59:26PM +0800, Zhen Lei wrote:
> The resources allocated by request_mem_region() is better to use
> release_mem_region() to free. These two functions are paired.

Does this fix a bug or some other issue?

It _looks_ ok but there is just enough complexity here that I wonder if it is
worth changing this without a good reason.

OTOH is there some way to make release_mem_region() more specific about which
resource is getting free'ed?

Ira

> 
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
>  drivers/dax/kmem.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index 275aa5f873991af..9e38f9c2b6d7f02 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -82,8 +82,7 @@ int dev_dax_kmem_probe(struct device *dev)
>  	rc = add_memory_driver_managed(numa_node, new_res->start,
>  				       resource_size(new_res), kmem_name);
>  	if (rc) {
> -		release_resource(new_res);
> -		kfree(new_res);
> +		release_mem_region(kmem_start, kmem_size);
>  		kfree(new_res_name);
>  		return rc;
>  	}
> @@ -118,8 +117,7 @@ static int dev_dax_kmem_remove(struct device *dev)
>  	}
>  
>  	/* Release and free dax resources */
> -	release_resource(res);
> -	kfree(res);
> +	release_mem_region(kmem_start, kmem_size);
>  	kfree(res_name);
>  	dev_dax->dax_kmem_res = NULL;
>  
> -- 
> 1.8.3
> 
> _______________________________________________
> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] device-dax: fix mismatches of request_mem_region()
  2020-08-17 18:57 ` Ira Weiny
@ 2020-08-18  2:20   ` Leizhen (ThunderTown)
  0 siblings, 0 replies; 3+ messages in thread
From: Leizhen (ThunderTown) @ 2020-08-18  2:20 UTC (permalink / raw)
  To: Ira Weiny; +Cc: Andrew Morton, linux-nvdimm



On 8/18/2020 2:57 AM, Ira Weiny wrote:
> On Mon, Aug 17, 2020 at 02:59:26PM +0800, Zhen Lei wrote:
>> The resources allocated by request_mem_region() is better to use
>> release_mem_region() to free. These two functions are paired.
> 
> Does this fix a bug or some other issue?
> 
> It _looks_ ok but there is just enough complexity here that I wonder if it is
> worth changing this without a good reason.
It's just that everyone uses it in this way. In fact, there's a similar patch:
b88aa8509828b56 mfd: sm501: Fix mismatches of request_mem_region

I used the subject directly. And we can found some examples in other places:
vi drivers/acpi/acpi_extlog.c +283 	in extlog_init()


> 
> OTOH is there some way to make release_mem_region() more specific about which
> resource is getting free'ed?

* __release_region - release a previously reserved resource region

As long as we pass the parameters correctly, it will work well.

> 
> Ira
> 
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  drivers/dax/kmem.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
>> index 275aa5f873991af..9e38f9c2b6d7f02 100644
>> --- a/drivers/dax/kmem.c
>> +++ b/drivers/dax/kmem.c
>> @@ -82,8 +82,7 @@ int dev_dax_kmem_probe(struct device *dev)
>>  	rc = add_memory_driver_managed(numa_node, new_res->start,
>>  				       resource_size(new_res), kmem_name);
>>  	if (rc) {
>> -		release_resource(new_res);
>> -		kfree(new_res);
>> +		release_mem_region(kmem_start, kmem_size);
>>  		kfree(new_res_name);
>>  		return rc;
>>  	}
>> @@ -118,8 +117,7 @@ static int dev_dax_kmem_remove(struct device *dev)
>>  	}
>>  
>>  	/* Release and free dax resources */
>> -	release_resource(res);
>> -	kfree(res);
>> +	release_mem_region(kmem_start, kmem_size);
>>  	kfree(res_name);
>>  	dev_dax->dax_kmem_res = NULL;
>>  
>> -- 
>> 1.8.3
>>
>> _______________________________________________
>> Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
>> To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
> 
> .
> 
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-18  2:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17  6:59 [PATCH 1/1] device-dax: fix mismatches of request_mem_region() Zhen Lei
2020-08-17 18:57 ` Ira Weiny
2020-08-18  2:20   ` Leizhen (ThunderTown)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.