[PATCH] Staging: android: ashmem: changed struct file_operations to const file_operations

kernel test robot lkp at intel.com
Fri Oct 16 06:20:55 UTC 2020


Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/kiransuren-osuosl-org/Staging-android-ashmem-changed-struct-file_operations-to-const-file_operations/20201016-131238
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 726eb70e0d34dc4bc4dada71f52bba8ed638431e
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
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
        # https://github.com/0day-ci/linux/commit/1496e5f2103cc6f96af90aaf323cf92f018dcf41
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review kiransuren-osuosl-org/Staging-android-ashmem-changed-struct-file_operations-to-const-file_operations/20201016-131238
        git checkout 1496e5f2103cc6f96af90aaf323cf92f018dcf41
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa 

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

All errors (new ones prefixed by >>):

   drivers/staging/android/ashmem.c: In function 'ashmem_mmap':
>> drivers/staging/android/ashmem.c:379:15: error: unknown type name 'file_operations'
     379 |  static const file_operations vmfile_fops;
         |               ^~~~~~~~~~~~~~~
>> drivers/staging/android/ashmem.c:429:19: error: request for member 'mmap' in something not a structure or union
     429 |   if (!vmfile_fops.mmap) {
         |                   ^
>> drivers/staging/android/ashmem.c:430:16: error: assignment of read-only variable 'vmfile_fops'
     430 |    vmfile_fops = *vmfile->f_op;
         |                ^
   drivers/staging/android/ashmem.c:431:15: error: request for member 'mmap' in something not a structure or union
     431 |    vmfile_fops.mmap = ashmem_vmfile_mmap;
         |               ^
>> drivers/staging/android/ashmem.c:432:15: error: request for member 'get_unmapped_area' in something not a structure or union
     432 |    vmfile_fops.get_unmapped_area =
         |               ^
>> drivers/staging/android/ashmem.c:435:16: error: assignment to 'const struct file_operations *' from incompatible pointer type 'const int *' [-Werror=incompatible-pointer-types]
     435 |   vmfile->f_op = &vmfile_fops;
         |                ^
   cc1: some warnings being treated as errors

vim +/file_operations +379 drivers/staging/android/ashmem.c

   376	
   377	static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
   378	{
 > 379		static const file_operations vmfile_fops;
   380		struct ashmem_area *asma = file->private_data;
   381		int ret = 0;
   382	
   383		mutex_lock(&ashmem_mutex);
   384	
   385		/* user needs to SET_SIZE before mapping */
   386		if (!asma->size) {
   387			ret = -EINVAL;
   388			goto out;
   389		}
   390	
   391		/* requested mapping size larger than object size */
   392		if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
   393			ret = -EINVAL;
   394			goto out;
   395		}
   396	
   397		/* requested protection bits must match our allowed protection mask */
   398		if ((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
   399		    calc_vm_prot_bits(PROT_MASK, 0)) {
   400			ret = -EPERM;
   401			goto out;
   402		}
   403		vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask);
   404	
   405		if (!asma->file) {
   406			char *name = ASHMEM_NAME_DEF;
   407			struct file *vmfile;
   408			struct inode *inode;
   409	
   410			if (asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0')
   411				name = asma->name;
   412	
   413			/* ... and allocate the backing shmem file */
   414			vmfile = shmem_file_setup(name, asma->size, vma->vm_flags);
   415			if (IS_ERR(vmfile)) {
   416				ret = PTR_ERR(vmfile);
   417				goto out;
   418			}
   419			vmfile->f_mode |= FMODE_LSEEK;
   420			inode = file_inode(vmfile);
   421			lockdep_set_class(&inode->i_rwsem, &backing_shmem_inode_class);
   422			asma->file = vmfile;
   423			/*
   424			 * override mmap operation of the vmfile so that it can't be
   425			 * remapped which would lead to creation of a new vma with no
   426			 * asma permission checks. Have to override get_unmapped_area
   427			 * as well to prevent VM_BUG_ON check for f_ops modification.
   428			 */
 > 429			if (!vmfile_fops.mmap) {
 > 430				vmfile_fops = *vmfile->f_op;
   431				vmfile_fops.mmap = ashmem_vmfile_mmap;
 > 432				vmfile_fops.get_unmapped_area =
   433						ashmem_vmfile_get_unmapped_area;
   434			}
 > 435			vmfile->f_op = &vmfile_fops;
   436		}
   437		get_file(asma->file);
   438	
   439		/*
   440		 * XXX - Reworked to use shmem_zero_setup() instead of
   441		 * shmem_set_file while we're in staging. -jstultz
   442		 */
   443		if (vma->vm_flags & VM_SHARED) {
   444			ret = shmem_zero_setup(vma);
   445			if (ret) {
   446				fput(asma->file);
   447				goto out;
   448			}
   449		} else {
   450			vma_set_anonymous(vma);
   451		}
   452	
   453		if (vma->vm_file)
   454			fput(vma->vm_file);
   455		vma->vm_file = asma->file;
   456	
   457	out:
   458		mutex_unlock(&ashmem_mutex);
   459		return ret;
   460	}
   461	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 65636 bytes
Desc: not available
URL: <http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/attachments/20201016/7e7ba000/attachment-0001.bin>


More information about the devel mailing list