All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/hmm/test: fix an error code in hmm_dmirror_init()
@ 2020-05-13  9:42 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-05-13  9:42 UTC (permalink / raw)
  To: Jérôme Glisse, Ralph Campbell; +Cc: linux-mm, kernel-janitors

If the allocation fails, then this should return -ENOMEM instead of
success.

Fixes: a149d2eb654b ("mm/hmm/test: add selftest driver for HMM")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 00bca6116f930..b4d9434e49e72 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1119,8 +1119,10 @@ static int __init hmm_dmirror_init(void)
 	 * make the code here simpler (i.e., we need a struct page for it).
 	 */
 	dmirror_zero_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
-	if (!dmirror_zero_page)
+	if (!dmirror_zero_page) {
+		ret = -ENOMEM;
 		goto err_chrdev;
+	}
 
 	pr_info("HMM test module loaded. This is only for testing HMM.\n");
 	return 0;
-- 
2.26.2

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

* [PATCH] mm/hmm/test: fix an error code in hmm_dmirror_init()
@ 2020-05-13  9:42 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-05-13  9:42 UTC (permalink / raw)
  To: Jérôme Glisse, Ralph Campbell; +Cc: linux-mm, kernel-janitors

If the allocation fails, then this should return -ENOMEM instead of
success.

Fixes: a149d2eb654b ("mm/hmm/test: add selftest driver for HMM")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index 00bca6116f930..b4d9434e49e72 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -1119,8 +1119,10 @@ static int __init hmm_dmirror_init(void)
 	 * make the code here simpler (i.e., we need a struct page for it).
 	 */
 	dmirror_zero_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
-	if (!dmirror_zero_page)
+	if (!dmirror_zero_page) {
+		ret = -ENOMEM;
 		goto err_chrdev;
+	}
 
 	pr_info("HMM test module loaded. This is only for testing HMM.\n");
 	return 0;
-- 
2.26.2



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

* Re: [PATCH] mm/hmm/test: fix an error code in hmm_dmirror_init()
  2020-05-13  9:42 ` Dan Carpenter
@ 2020-05-13 19:08   ` Ralph Campbell
  -1 siblings, 0 replies; 8+ messages in thread
From: Ralph Campbell @ 2020-05-13 19:08 UTC (permalink / raw)
  To: Dan Carpenter, Jérôme Glisse; +Cc: linux-mm, kernel-janitors


On 5/13/20 2:42 AM, Dan Carpenter wrote:
> If the allocation fails, then this should return -ENOMEM instead of
> success.
> 
> Fixes: a149d2eb654b ("mm/hmm/test: add selftest driver for HMM")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   lib/test_hmm.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 00bca6116f930..b4d9434e49e72 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -1119,8 +1119,10 @@ static int __init hmm_dmirror_init(void)
>   	 * make the code here simpler (i.e., we need a struct page for it).
>   	 */
>   	dmirror_zero_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
> -	if (!dmirror_zero_page)
> +	if (!dmirror_zero_page) {
> +		ret = -ENOMEM;
>   		goto err_chrdev;
> +	}
>   
>   	pr_info("HMM test module loaded. This is only for testing HMM.\n");
>   	return 0;
> 

Thanks for fixing this. It looks like Wei Yongjun beat you to it
and Jason Gunthorpe has applied it to the hmm tree.

https://lore.kernel.org/linux-mm/20200512195932.GB9154@ziepe.ca/

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

* Re: [PATCH] mm/hmm/test: fix an error code in hmm_dmirror_init()
@ 2020-05-13 19:08   ` Ralph Campbell
  0 siblings, 0 replies; 8+ messages in thread
From: Ralph Campbell @ 2020-05-13 19:08 UTC (permalink / raw)
  To: Dan Carpenter, Jérôme Glisse; +Cc: linux-mm, kernel-janitors


On 5/13/20 2:42 AM, Dan Carpenter wrote:
> If the allocation fails, then this should return -ENOMEM instead of
> success.
> 
> Fixes: a149d2eb654b ("mm/hmm/test: add selftest driver for HMM")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>   lib/test_hmm.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 00bca6116f930..b4d9434e49e72 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -1119,8 +1119,10 @@ static int __init hmm_dmirror_init(void)
>   	 * make the code here simpler (i.e., we need a struct page for it).
>   	 */
>   	dmirror_zero_page = alloc_page(GFP_HIGHUSER | __GFP_ZERO);
> -	if (!dmirror_zero_page)
> +	if (!dmirror_zero_page) {
> +		ret = -ENOMEM;
>   		goto err_chrdev;
> +	}
>   
>   	pr_info("HMM test module loaded. This is only for testing HMM.\n");
>   	return 0;
> 

Thanks for fixing this. It looks like Wei Yongjun beat you to it
and Jason Gunthorpe has applied it to the hmm tree.

https://lore.kernel.org/linux-mm/20200512195932.GB9154@ziepe.ca/


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

* [PATCH] mm/hmm/test: Fix an error code in dmirror_allocate_chunk()
@ 2020-10-10 20:08   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-10-10 20:08 UTC (permalink / raw)
  To: Jérôme Glisse
  Cc: Stephen Rothwell, Ralph Campbell, Jason Gunthorpe, Dan Williams,
	Andrew Morton, linux-mm, kernel-janitors

This is supposed to return false on failure, not a negative error code.

Fixes: 170e38548b81 ("mm/hmm/test: use after free in dmirror_allocate_chunk()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I messed this up earlier...  My devel version of Smatch prints too much
garbage so I missed the warning when I first wrote the patch.  :/
Sorry.

 lib/test_hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index e151a7f10519..80a78877bd93 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -461,7 +461,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
 
 	devmem = kzalloc(sizeof(*devmem), GFP_KERNEL);
 	if (!devmem)
-		return -ENOMEM;
+		return false;
 
 	res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE,
 				      "hmm_dmirror");
-- 
2.28.0

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

* [PATCH] mm/hmm/test: Fix an error code in dmirror_allocate_chunk()
@ 2020-10-10 20:08   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2020-10-10 20:08 UTC (permalink / raw)
  To: Jérôme Glisse
  Cc: Stephen Rothwell, Ralph Campbell, Jason Gunthorpe, Dan Williams,
	Andrew Morton, linux-mm, kernel-janitors

This is supposed to return false on failure, not a negative error code.

Fixes: 170e38548b81 ("mm/hmm/test: use after free in dmirror_allocate_chunk()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I messed this up earlier...  My devel version of Smatch prints too much
garbage so I missed the warning when I first wrote the patch.  :/
Sorry.

 lib/test_hmm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_hmm.c b/lib/test_hmm.c
index e151a7f10519..80a78877bd93 100644
--- a/lib/test_hmm.c
+++ b/lib/test_hmm.c
@@ -461,7 +461,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
 
 	devmem = kzalloc(sizeof(*devmem), GFP_KERNEL);
 	if (!devmem)
-		return -ENOMEM;
+		return false;
 
 	res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE,
 				      "hmm_dmirror");
-- 
2.28.0



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

* Re: [PATCH] mm/hmm/test: Fix an error code in dmirror_allocate_chunk()
  2020-10-10 20:08   ` Dan Carpenter
@ 2020-10-11 20:58     ` Ralph Campbell
  -1 siblings, 0 replies; 8+ messages in thread
From: Ralph Campbell @ 2020-10-11 20:58 UTC (permalink / raw)
  To: Dan Carpenter, Jérôme Glisse
  Cc: Stephen Rothwell, Jason Gunthorpe, Dan Williams, Andrew Morton,
	linux-mm, kernel-janitors


On 10/10/20 1:08 PM, Dan Carpenter wrote:
> This is supposed to return false on failure, not a negative error code.
> 
> Fixes: 170e38548b81 ("mm/hmm/test: use after free in dmirror_allocate_chunk()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I messed this up earlier...  My devel version of Smatch prints too much
> garbage so I missed the warning when I first wrote the patch.  :/
> Sorry.
> 
>   lib/test_hmm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index e151a7f10519..80a78877bd93 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -461,7 +461,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
>   
>   	devmem = kzalloc(sizeof(*devmem), GFP_KERNEL);
>   	if (!devmem)
> -		return -ENOMEM;
> +		return false;
>   
>   	res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE,
>   				      "hmm_dmirror");

Thanks for fixing this.
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>

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

* Re: [PATCH] mm/hmm/test: Fix an error code in dmirror_allocate_chunk()
@ 2020-10-11 20:58     ` Ralph Campbell
  0 siblings, 0 replies; 8+ messages in thread
From: Ralph Campbell @ 2020-10-11 20:58 UTC (permalink / raw)
  To: Dan Carpenter, Jérôme Glisse
  Cc: Stephen Rothwell, Jason Gunthorpe, Dan Williams, Andrew Morton,
	linux-mm, kernel-janitors


On 10/10/20 1:08 PM, Dan Carpenter wrote:
> This is supposed to return false on failure, not a negative error code.
> 
> Fixes: 170e38548b81 ("mm/hmm/test: use after free in dmirror_allocate_chunk()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I messed this up earlier...  My devel version of Smatch prints too much
> garbage so I missed the warning when I first wrote the patch.  :/
> Sorry.
> 
>   lib/test_hmm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index e151a7f10519..80a78877bd93 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -461,7 +461,7 @@ static bool dmirror_allocate_chunk(struct dmirror_device *mdevice,
>   
>   	devmem = kzalloc(sizeof(*devmem), GFP_KERNEL);
>   	if (!devmem)
> -		return -ENOMEM;
> +		return false;
>   
>   	res = request_free_mem_region(&iomem_resource, DEVMEM_CHUNK_SIZE,
>   				      "hmm_dmirror");

Thanks for fixing this.
Reviewed-by: Ralph Campbell <rcampbell@nvidia.com>


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

end of thread, other threads:[~2020-10-11 20:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13  9:42 [PATCH] mm/hmm/test: fix an error code in hmm_dmirror_init() Dan Carpenter
2020-05-13  9:42 ` Dan Carpenter
2020-05-13 19:08 ` Ralph Campbell
2020-05-13 19:08   ` Ralph Campbell
2020-10-10 20:08 ` [PATCH] mm/hmm/test: Fix an error code in dmirror_allocate_chunk() Dan Carpenter
2020-10-10 20:08   ` Dan Carpenter
2020-10-11 20:58   ` Ralph Campbell
2020-10-11 20:58     ` Ralph Campbell

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.