diff mbox series

mm/hmm/test: Fix an error code in dmirror_allocate_chunk()

Message ID 20201010200812.GA1886610@mwanda (mailing list archive)
State New, archived
Headers show
Series mm/hmm/test: Fix an error code in dmirror_allocate_chunk() | expand

Commit Message

Dan Carpenter Oct. 10, 2020, 8:08 p.m. UTC
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(-)

Comments

Ralph Campbell Oct. 11, 2020, 8:58 p.m. UTC | #1
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>
diff mbox series

Patch

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");