Thread (18 messages) flat view 18 messages, 4 authors, 2022-06-16

Re: [RFC PATCH 6/6] pkeys: Change mm_pkey_free() to void

From: Ira Weiny <hidden>
Date: 2022-06-13 19:00:29
Also in: linux-api, linux-kselftest, linux-mm, lkml

On Mon, Jun 13, 2022 at 09:17:06AM +0000, Christophe Leroy wrote:

Le 11/06/2022 à 01:35, ira.weiny@intel.com a écrit :
quoted
From: Ira Weiny <redacted>

Now that the pkey arch support is no longer checked in mm_pkey_free()
there is no reason to have it return int.
Right, I see this is doing what I commented in previous patch.
Yes because it was suggested by Sohil I decided to make it a separate patch to
make the credit easier.
quoted
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 41458e729c27..e872bdd2e228 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -809,8 +809,10 @@ SYSCALL_DEFINE1(pkey_free, int, pkey)
  		return ret;
  
  	mmap_write_lock(current->mm);
-	if (mm_pkey_is_allocated(current->mm, pkey))
-		ret = mm_pkey_free(current->mm, pkey);
+	if (mm_pkey_is_allocated(current->mm, pkey)) {
+		mm_pkey_free(current->mm, pkey);
+		ret = 0;
+	}
Or you could have ret = 0 by default and do

	if (mm_pkey_is_allocated(current->mm, pkey))
		mm_pkey_free(current->mm, pkey);
	else
		ret = -EINVAL;
Yes that fits the kernel style better.

Thanks for the review!
Ira
quoted
  	mmap_write_unlock(current->mm);
  
  	/*
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help