Skip to contentSkip to conversation

mm/hmm/test: fix error return code in hmm_dmirror_init()

PATCH In review Wei Yongjun 3 participants 3 messages May 9, 2020 – May 12, 2020

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

PATCH 1/1 mm/hmm/test: fix error return code in hmm_dmirror_init()

Fix to return negative error code -ENOMEM from the alloc_page() error handling case instead of 0, as done elsewhere in this function.

Fixes 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/test_hmm.c +3 -1
index 00bca6116f93..b4d9434e49e7 100644
@@ -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;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Wei Yongjun

Fix to return negative error code -ENOMEM from the alloc_page() error handling case instead of 0, as done elsewhere in this function.

Fixes 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")

Looks good, thanks!

Quoted 23 lines
---
  lib/test_hmm.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
lib/test_hmm.c +3 -1
index 00bca6116f93..b4d9434e49e7 100644
@@ -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 lore raw
In reply to Wei Yongjun
Quoted 9 lines · Wei Yongjun

Fix to return negative error code -ENOMEM from the alloc_page() error handling case instead of 0, as done elsewhere in this function.

Fixes 5d5e54be8a1e ("mm/hmm/test: add selftest driver for HMM")
---
 lib/test_hmm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Thank you, I squashed this into the original commit

Jason