Skip to contentSkip to conversation

ion: Make user_ion_handle_put_nolock() a void function

PATCH Applied Nathan Chancellor 2 participants 3 messages Jul 27, 2022 – Aug 1, 2022

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

PATCH 1/1 ion: Make user_ion_handle_put_nolock() a void function

Clang warns:

drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

          if (--handle->user_ref_count == 0)
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:74:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/staging/android/ion/ion-ioctl.c:71:2: note: remove the 'if' if its condition is always true
          if (--handle->user_ref_count == 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:69:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0

1 warning generated.

The return value of user_ion_handle_put_nolock() is not checked in its one call site in user_ion_free_nolock() so just make user_ion_handle_put_nolock() return void to remove the warning.

Fixes a8200613c8c9 ("ion: Protect kref from userspace manipulation")
---
 drivers/staging/android/ion/ion-ioctl.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/android/ion/ion-ioctl.c +2 -6
index a27865b94416..e020a23d05f2 100644
@@ -64,14 +64,10 @@ static struct ion_handle *pass_to_user(struct ion_handle *handle)
 }
 
 /* Must hold the client lock */
-static int user_ion_handle_put_nolock(struct ion_handle *handle)
+static void user_ion_handle_put_nolock(struct ion_handle *handle)
 {
-	int ret;
-
 	if (--handle->user_ref_count == 0)
-		ret = ion_handle_put_nolock(handle);
-
-	return ret;
+		ion_handle_put_nolock(handle);
 }
 
 static void user_ion_free_nolock(struct ion_client *client,

base-commit: 65be5f5665a580424a7b1102f1a04c4259c559b5

Signature · 1 line
2.37.1
maintainer Applied
#1 lore raw

Patch "ion: Make user_ion_handle_put_nolock() a void function" has been added to the 4.9-stable tree

This is a note to let you know that I've just added the patch titled

ion: Make user_ion_handle_put_nolock() a void function

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
ion-make-user_ion_handle_put_nolock-a-void-function.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

From [email protected] Mon Aug 1 10:53:38 2022
From: Nathan Chancellor <[email protected]>
Date: Wed, 27 Jul 2022 09:46:17 -0700
Subject: ion: Make user_ion_handle_put_nolock() a void function
To: Greg Kroah-Hartman <[email protected]>, Sasha Levin <[email protected]>
Cc: Daniel Rosenberg <[email protected]>, [email protected], [email protected], Nathan Chancellor <[email protected]>, kernel test robot <[email protected]>
Message-ID: <[email protected]>

From: Nathan Chancellor <[email protected]>

Clang warns:

drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

          if (--handle->user_ref_count == 0)
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:74:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/staging/android/ion/ion-ioctl.c:71:2: note: remove the 'if' if its condition is always true
          if (--handle->user_ref_count == 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:69:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0

1 warning generated.

The return value of user_ion_handle_put_nolock() is not checked in its one call site in user_ion_free_nolock() so just make user_ion_handle_put_nolock() return void to remove the warning.

Fixes a8200613c8c9 ("ion: Protect kref from userspace manipulation")
---
 drivers/staging/android/ion/ion-ioctl.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/android/ion/ion-ioctl.c +2 -6
@@ -64,14 +64,10 @@ static struct ion_handle *pass_to_user(s
 }
 
 /* Must hold the client lock */
-static int user_ion_handle_put_nolock(struct ion_handle *handle)
+static void user_ion_handle_put_nolock(struct ion_handle *handle)
 {
-	int ret;
-
 	if (--handle->user_ref_count == 0)
-		ret = ion_handle_put_nolock(handle);
-
-	return ret;
+		ion_handle_put_nolock(handle);
 }
 
 static void user_ion_free_nolock(struct ion_client *client,

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/arm-crypto-comment-out-gcc-warning-that-breaks-clang-builds.patch queue-4.9/ion-make-user_ion_handle_put_nolock-a-void-function.patch

maintainer
#2 lore raw
In reply to Nathan Chancellor
Quoted 21 lines · Nathan Chancellor

Clang warns:

drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

          if (--handle->user_ref_count == 0)
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:74:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  drivers/staging/android/ion/ion-ioctl.c:71:2: note: remove the 'if' if its condition is always true
          if (--handle->user_ref_count == 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  drivers/staging/android/ion/ion-ioctl.c:69:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0

1 warning generated.

The return value of user_ion_handle_put_nolock() is not checked in its one call site in user_ion_free_nolock() so just make user_ion_handle_put_nolock() return void to remove the warning.

Quoted 6 lines
Fixes a8200613c8c9 ("ion: Protect kref from userspace manipulation")
---
 drivers/staging/android/ion/ion-ioctl.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Now queued up, thanks.

greg k-h