All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: kernel test robot <lkp@intel.com>
Cc: Daniel Rosenberg <drosen@google.com>,
	llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Dennis Cagle <d-cagle@codeaurora.org>,
	Lee Jones <lee.jones@linaro.org>
Subject: Re: [linux-stable-rc:linux-4.9.y 967/2229] drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false
Date: Mon, 25 Jul 2022 08:39:07 -0700	[thread overview]
Message-ID: <Yt65G3x2Hmoj4q/b@Ryzen-9-3900X.> (raw)
In-Reply-To: <202207241311.Dv86CbAo-lkp@intel.com>

On Sun, Jul 24, 2022 at 01:39:50PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
> head:   65be5f5665a580424a7b1102f1a04c4259c559b5
> commit: a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e [967/2229] ion: Protect kref from userspace manipulation
> config: mips-randconfig-r034-20220719 (https://download.01.org/0day-ci/archive/20220724/202207241311.Dv86CbAo-lkp@intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project fa0c7639e91fa1cd0cf2ff0445a1634a90fe850a)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install mips cross compiling tool for clang build
>         # apt-get install binutils-mipsel-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e
>         git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
>         git fetch --no-tags linux-stable-rc linux-4.9.y
>         git checkout a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/staging/android/ion/
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
> >> 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.
> 
> 
> vim +71 drivers/staging/android/ion/ion-ioctl.c
> 
>     65	
>     66	/* Must hold the client lock */
>     67	static int user_ion_handle_put_nolock(struct ion_handle *handle)
>     68	{
>     69		int ret;
>     70	
>   > 71		if (--handle->user_ref_count == 0)
>     72			ret = ion_handle_put_nolock(handle);
>     73	
>     74		return ret;
>     75	}
>     76	

Might as well just be

static void user_ion_handle_put_nolock(struct ion_handle *handle)
{
	if (--handle->user_ref_count == 0)
		ion_handle_put_nolock(handle);
}

since user_ion_free_nolock() doesn't check the return value of
user_ion_handle_put_nolock()? I can send a patch if people care (I know
4.9 is a bit on the older side).

Cheers,
Nathan

WARNING: multiple messages have this Message-ID (diff)
From: Nathan Chancellor <nathan@kernel.org>
To: kbuild-all@lists.01.org
Subject: Re: [linux-stable-rc:linux-4.9.y 967/2229] drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false
Date: Mon, 25 Jul 2022 08:39:07 -0700	[thread overview]
Message-ID: <Yt65G3x2Hmoj4q/b@Ryzen-9-3900X.> (raw)
In-Reply-To: <202207241311.Dv86CbAo-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3221 bytes --]

On Sun, Jul 24, 2022 at 01:39:50PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
> head:   65be5f5665a580424a7b1102f1a04c4259c559b5
> commit: a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e [967/2229] ion: Protect kref from userspace manipulation
> config: mips-randconfig-r034-20220719 (https://download.01.org/0day-ci/archive/20220724/202207241311.Dv86CbAo-lkp(a)intel.com/config)
> compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project fa0c7639e91fa1cd0cf2ff0445a1634a90fe850a)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install mips cross compiling tool for clang build
>         # apt-get install binutils-mipsel-linux-gnu
>         # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e
>         git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
>         git fetch --no-tags linux-stable-rc linux-4.9.y
>         git checkout a8200613c8c9fbaf7b55d4d438376ebaf0c4ce7e
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash drivers/staging/android/ion/
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
> >> 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.
> 
> 
> vim +71 drivers/staging/android/ion/ion-ioctl.c
> 
>     65	
>     66	/* Must hold the client lock */
>     67	static int user_ion_handle_put_nolock(struct ion_handle *handle)
>     68	{
>     69		int ret;
>     70	
>   > 71		if (--handle->user_ref_count == 0)
>     72			ret = ion_handle_put_nolock(handle);
>     73	
>     74		return ret;
>     75	}
>     76	

Might as well just be

static void user_ion_handle_put_nolock(struct ion_handle *handle)
{
	if (--handle->user_ref_count == 0)
		ion_handle_put_nolock(handle);
}

since user_ion_free_nolock() doesn't check the return value of
user_ion_handle_put_nolock()? I can send a patch if people care (I know
4.9 is a bit on the older side).

Cheers,
Nathan

  reply	other threads:[~2022-07-25 15:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-24  5:39 [linux-stable-rc:linux-4.9.y 967/2229] drivers/staging/android/ion/ion-ioctl.c:71:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false kernel test robot
2022-07-25 15:39 ` Nathan Chancellor [this message]
2022-07-25 15:39   ` Nathan Chancellor
     [not found] ` <62deb91e.1c69fb81.96632.74a9SMTPIN_ADDED_BROKEN@mx.google.com>
2022-07-27 10:08   ` Greg Kroah-Hartman
2022-07-27 10:08     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yt65G3x2Hmoj4q/b@Ryzen-9-3900X. \
    --to=nathan@kernel.org \
    --cc=d-cagle@codeaurora.org \
    --cc=drosen@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.