Skip to contentSkip to conversation

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

PATCH Applied Dan Carpenter 2 participants 2 messages Oct 10, 2020 – Oct 11, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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

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

---
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(-)
lib/test_hmm.c +1 -1
index e151a7f10519..80a78877bd93 100644
@@ -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");
Signature · 1 line
2.28.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Dan Carpenter

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

---
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(-)
lib/test_hmm.c +0 -0
index e151a7f10519..80a78877bd93 100644

lib/test_hmm.c static bool dmirror_allocate_chunk(struct dmirror_device *mdevice, · line 467

Quoted 8 lines
lib/test_hmm.c +1 -1
@@ -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.