All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 10422/12330] drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:970:13: warning: variable 'userdata' is used uninitialized whenever 'if' condition is false
@ 2020-09-30 22:30 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-09-30 22:30 UTC (permalink / raw)
  To: kbuild-all

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   de69ee6df1cfbf3c67787d8504fd21b59da39572
commit: 4184da4f316a549ae732d91088571fef46a2f58d [10422/12330] staging: vchiq: fix __user annotations
config: arm64-randconfig-r035-20200930 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project bcd05599d0e53977a963799d6ee4f6e0bc21331b)
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 arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=4184da4f316a549ae732d91088571fef46a2f58d
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout 4184da4f316a549ae732d91088571fef46a2f58d
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:970:13: warning: variable 'userdata' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           } else if (args->mode == VCHIQ_BULK_MODE_WAITING) {
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:1001:10: note: uninitialized use occurs here
                                        userdata, args->mode, dir);
                                        ^~~~~~~~
   drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:970:9: note: remove the 'if' if its condition is always true
           } else if (args->mode == VCHIQ_BULK_MODE_WAITING) {
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:953:16: note: initialize the variable 'userdata' to silence this warning
           void *userdata;
                         ^
                          = NULL
   1 warning generated.

vim +970 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

f618affa770c5da Arnd Bergmann 2020-09-18   945  
a4367cd2b231686 Arnd Bergmann 2020-09-18   946  static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
a4367cd2b231686 Arnd Bergmann 2020-09-18   947  				      struct vchiq_queue_bulk_transfer *args,
a4367cd2b231686 Arnd Bergmann 2020-09-18   948  				      enum vchiq_bulk_dir dir,
a4367cd2b231686 Arnd Bergmann 2020-09-18   949  				      enum vchiq_bulk_mode __user *mode)
a4367cd2b231686 Arnd Bergmann 2020-09-18   950  {
a4367cd2b231686 Arnd Bergmann 2020-09-18   951  	struct vchiq_service *service;
a4367cd2b231686 Arnd Bergmann 2020-09-18   952  	struct bulk_waiter_node *waiter = NULL;
4184da4f316a549 Arnd Bergmann 2020-09-25   953  	void *userdata;
a4367cd2b231686 Arnd Bergmann 2020-09-18   954  	int status = 0;
a4367cd2b231686 Arnd Bergmann 2020-09-18   955  	int ret;
a4367cd2b231686 Arnd Bergmann 2020-09-18   956  
a4367cd2b231686 Arnd Bergmann 2020-09-18   957  	service = find_service_for_instance(instance, args->handle);
a4367cd2b231686 Arnd Bergmann 2020-09-18   958  	if (!service)
a4367cd2b231686 Arnd Bergmann 2020-09-18   959  		return -EINVAL;
a4367cd2b231686 Arnd Bergmann 2020-09-18   960  
a4367cd2b231686 Arnd Bergmann 2020-09-18   961  	if (args->mode == VCHIQ_BULK_MODE_BLOCKING) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   962  		waiter = kzalloc(sizeof(struct bulk_waiter_node),
a4367cd2b231686 Arnd Bergmann 2020-09-18   963  			GFP_KERNEL);
a4367cd2b231686 Arnd Bergmann 2020-09-18   964  		if (!waiter) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   965  			ret = -ENOMEM;
a4367cd2b231686 Arnd Bergmann 2020-09-18   966  			goto out;
a4367cd2b231686 Arnd Bergmann 2020-09-18   967  		}
a4367cd2b231686 Arnd Bergmann 2020-09-18   968  
4184da4f316a549 Arnd Bergmann 2020-09-25   969  		userdata = &waiter->bulk_waiter;
a4367cd2b231686 Arnd Bergmann 2020-09-18  @970  	} else if (args->mode == VCHIQ_BULK_MODE_WAITING) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   971  		mutex_lock(&instance->bulk_waiter_list_mutex);
a4367cd2b231686 Arnd Bergmann 2020-09-18   972  		list_for_each_entry(waiter, &instance->bulk_waiter_list,
a4367cd2b231686 Arnd Bergmann 2020-09-18   973  				    list) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   974  			if (waiter->pid == current->pid) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   975  				list_del(&waiter->list);
a4367cd2b231686 Arnd Bergmann 2020-09-18   976  				break;
a4367cd2b231686 Arnd Bergmann 2020-09-18   977  			}
a4367cd2b231686 Arnd Bergmann 2020-09-18   978  		}
a4367cd2b231686 Arnd Bergmann 2020-09-18   979  		mutex_unlock(&instance->bulk_waiter_list_mutex);
a4367cd2b231686 Arnd Bergmann 2020-09-18   980  		if (!waiter) {
a4367cd2b231686 Arnd Bergmann 2020-09-18   981  			vchiq_log_error(vchiq_arm_log_level,
a4367cd2b231686 Arnd Bergmann 2020-09-18   982  				"no bulk_waiter found for pid %d",
a4367cd2b231686 Arnd Bergmann 2020-09-18   983  				current->pid);
a4367cd2b231686 Arnd Bergmann 2020-09-18   984  			ret = -ESRCH;
a4367cd2b231686 Arnd Bergmann 2020-09-18   985  			goto out;
a4367cd2b231686 Arnd Bergmann 2020-09-18   986  		}
a4367cd2b231686 Arnd Bergmann 2020-09-18   987  		vchiq_log_info(vchiq_arm_log_level,
a4367cd2b231686 Arnd Bergmann 2020-09-18   988  			"found bulk_waiter %pK for pid %d", waiter,
a4367cd2b231686 Arnd Bergmann 2020-09-18   989  			current->pid);
4184da4f316a549 Arnd Bergmann 2020-09-25   990  		userdata = &waiter->bulk_waiter;
a4367cd2b231686 Arnd Bergmann 2020-09-18   991  	}
a4367cd2b231686 Arnd Bergmann 2020-09-18   992  
4184da4f316a549 Arnd Bergmann 2020-09-25   993  	/*
4184da4f316a549 Arnd Bergmann 2020-09-25   994  	 * FIXME address space mismatch:
4184da4f316a549 Arnd Bergmann 2020-09-25   995  	 * args->data may be interpreted as a kernel pointer
4184da4f316a549 Arnd Bergmann 2020-09-25   996  	 * in create_pagelist() called from vchiq_bulk_transfer(),
4184da4f316a549 Arnd Bergmann 2020-09-25   997  	 * accessing kernel data instead of user space, based on the
4184da4f316a549 Arnd Bergmann 2020-09-25   998  	 * address.
4184da4f316a549 Arnd Bergmann 2020-09-25   999  	 */
a4367cd2b231686 Arnd Bergmann 2020-09-18  1000  	status = vchiq_bulk_transfer(args->handle, args->data, args->size,
4184da4f316a549 Arnd Bergmann 2020-09-25  1001  				     userdata, args->mode, dir);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1002  
a4367cd2b231686 Arnd Bergmann 2020-09-18  1003  	if (!waiter) {
a4367cd2b231686 Arnd Bergmann 2020-09-18  1004  		ret = 0;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1005  		goto out;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1006  	}
a4367cd2b231686 Arnd Bergmann 2020-09-18  1007  
a4367cd2b231686 Arnd Bergmann 2020-09-18  1008  	if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) ||
a4367cd2b231686 Arnd Bergmann 2020-09-18  1009  		!waiter->bulk_waiter.bulk) {
a4367cd2b231686 Arnd Bergmann 2020-09-18  1010  		if (waiter->bulk_waiter.bulk) {
a4367cd2b231686 Arnd Bergmann 2020-09-18  1011  			/* Cancel the signal when the transfer
a4367cd2b231686 Arnd Bergmann 2020-09-18  1012  			** completes. */
a4367cd2b231686 Arnd Bergmann 2020-09-18  1013  			spin_lock(&bulk_waiter_spinlock);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1014  			waiter->bulk_waiter.bulk->userdata = NULL;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1015  			spin_unlock(&bulk_waiter_spinlock);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1016  		}
a4367cd2b231686 Arnd Bergmann 2020-09-18  1017  		kfree(waiter);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1018  		ret = 0;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1019  	} else {
a4367cd2b231686 Arnd Bergmann 2020-09-18  1020  		const enum vchiq_bulk_mode mode_waiting =
a4367cd2b231686 Arnd Bergmann 2020-09-18  1021  			VCHIQ_BULK_MODE_WAITING;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1022  		waiter->pid = current->pid;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1023  		mutex_lock(&instance->bulk_waiter_list_mutex);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1024  		list_add(&waiter->list, &instance->bulk_waiter_list);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1025  		mutex_unlock(&instance->bulk_waiter_list_mutex);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1026  		vchiq_log_info(vchiq_arm_log_level,
a4367cd2b231686 Arnd Bergmann 2020-09-18  1027  			"saved bulk_waiter %pK for pid %d",
a4367cd2b231686 Arnd Bergmann 2020-09-18  1028  			waiter, current->pid);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1029  
a4367cd2b231686 Arnd Bergmann 2020-09-18  1030  		ret = put_user(mode_waiting, mode);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1031  	}
a4367cd2b231686 Arnd Bergmann 2020-09-18  1032  out:
a4367cd2b231686 Arnd Bergmann 2020-09-18  1033  	unlock_service(service);
a4367cd2b231686 Arnd Bergmann 2020-09-18  1034  	if (ret)
a4367cd2b231686 Arnd Bergmann 2020-09-18  1035  		return ret;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1036  	else if (status == VCHIQ_ERROR)
a4367cd2b231686 Arnd Bergmann 2020-09-18  1037  		return -EIO;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1038  	else if (status == VCHIQ_RETRY)
a4367cd2b231686 Arnd Bergmann 2020-09-18  1039  		return -EINTR;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1040  	return 0;
a4367cd2b231686 Arnd Bergmann 2020-09-18  1041  }
a4367cd2b231686 Arnd Bergmann 2020-09-18  1042  

:::::: The code at line 970 was first introduced by commit
:::::: a4367cd2b2316862c5085a6beb12511f9f57608b staging: vchiq: convert compat bulk transfer

:::::: TO: Arnd Bergmann <arnd@arndb.de>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 45557 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-30 22:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 22:30 [linux-next:master 10422/12330] drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:970:13: warning: variable 'userdata' is used uninitialized whenever 'if' condition is false kernel test robot

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.