Re: [PATCH] Staging: android: ashmem: fixed a struct without const

2021-03-06 Thread kernel test robot
Hi nabil5352,

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/nabil5352/Staging-android-ashmem-fixed-a-struct-without-const/20210307-103559
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
4e1c5d4c35d8d5a5f861019f1392ebaa0abb490b
config: x86_64-randconfig-m001-20210307 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# 
https://github.com/0day-ci/linux/commit/4847faabe2fac6d0cf216c0d7ad02e0a263945b4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
nabil5352/Staging-android-ashmem-fixed-a-struct-without-const/20210307-103559
git checkout 4847faabe2fac6d0cf216c0d7ad02e0a263945b4
# save the attached .config to linux build tree
make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   drivers/staging/android/ashmem.c: In function 'ashmem_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:21: error: assignment of member 'mmap' 
>> in read-only object
 431 |vmfile_fops.mmap = ashmem_vmfile_mmap;
 | ^
>> drivers/staging/android/ashmem.c:432:34: error: assignment of member 
>> 'get_unmapped_area' in read-only object
 432 |vmfile_fops.get_unmapped_area =
 |  ^


vim +/vmfile_fops +430 drivers/staging/android/ashmem.c

6d67b0290b4b84 Suren Baghdasaryan 2020-01-27  376  
11980c2ac4ccfa Robert Love2011-12-20  377  static int 
ashmem_mmap(struct file *file, struct vm_area_struct *vma)
11980c2ac4ccfa Robert Love2011-12-20  378  {
4847faabe2fac6 nabil5352  2021-03-06  379   static const struct 
file_operations vmfile_fops;
11980c2ac4ccfa Robert Love2011-12-20  380   struct ashmem_area 
*asma = file->private_data;
11980c2ac4ccfa Robert Love2011-12-20  381   int ret = 0;
11980c2ac4ccfa Robert Love2011-12-20  382  
11980c2ac4ccfa Robert Love2011-12-20  383   
mutex_lock(_mutex);
11980c2ac4ccfa Robert Love2011-12-20  384  
11980c2ac4ccfa Robert Love2011-12-20  385   /* user needs to 
SET_SIZE before mapping */
59848d6aded59a Alistair Strachan  2018-06-19  386   if (!asma->size) {
11980c2ac4ccfa Robert Love2011-12-20  387   ret = -EINVAL;
11980c2ac4ccfa Robert Love2011-12-20  388   goto out;
11980c2ac4ccfa Robert Love2011-12-20  389   }
11980c2ac4ccfa Robert Love2011-12-20  390  
8632c614565d0c Alistair Strachan  2018-06-19  391   /* requested mapping 
size larger than object size */
8632c614565d0c Alistair Strachan  2018-06-19  392   if (vma->vm_end - 
vma->vm_start > PAGE_ALIGN(asma->size)) {
11980c2ac4ccfa Robert Love2011-12-20  393   ret = -EINVAL;
11980c2ac4ccfa Robert Love2011-12-20  394   goto out;
11980c2ac4ccfa Robert Love2011-12-20  395   }
11980c2ac4ccfa Robert Love2011-12-20  396  
11980c2ac4ccfa Robert Love2011-12-20  397   /* requested protection 
bits must match our allowed protection mask */
59848d6aded59a Alistair Strachan  2018-06-19  398   if ((vma->vm_flags & 
~calc_vm_prot_bits(asma->prot_mask, 0)) &
59848d6aded59a Alistair Strachan  2018-06-19  399   
calc_vm_prot_bits(PROT_MASK, 0)) {
11980c2ac4ccfa Robert Love2011-12-20  400   ret = -EPERM;
11980c2ac4ccfa Robert Love2011-12-20  401   goto out;
11980c2ac4ccfa Robert Love2011-12-20  402   }
56f76fc68492af Arve Hjønnevåg 2011-12-20  403   vma->vm_flags &= 
~calc_vm_may_flags(~asma->prot_mask);
11980c2ac4ccfa Robert Love2011-12-20  404  
11980c2ac4ccfa Robert Love2011-12-20  405   if (!asma->file) {
11980c2ac4ccfa Robert Love2011-12-20  406   char *name = 
ASHMEM_NAME_DEF;
11980c2ac4ccfa Robert Love2011-12-20  407   struct file 
*vmfile;
3e338d3c95c735 Suren Baghdasaryan 2020-07-30  408   struct inode 
*inode;
11980c2ac4ccfa Robert Love2011-12-20  409  
11980c2ac4ccfa Robert Love2011-12-20  410   if 
(asma->name[ASHMEM_NAME_PREFIX_LEN] != '\0')
11980c2ac4ccfa Robert Love2011-12-20  411   name = 
asma->name;
11980c2ac4ccfa Robert Love2011-12-20  412  
11980c2ac4ccfa Robert Love2011-12-20  413   /* ... and 
allocate the backing shmem file */
11980c2ac4ccfa Robert Love2011-12-20  414   vmfile = 
shmem_file_setup(name, asma->size, vma->vm_flags);
7f44cb0ba88b40 Viresh 

Re: [PATCH] Staging: android: ashmem: fixed a struct without const

2021-03-06 Thread Greg KH
On Sat, Mar 06, 2021 at 12:38:17PM +0600, nabil5352 wrote:
> Fixed a struct without const
> 
> Signed-off-by: nabil5352 
> ---
>  drivers/staging/android/ashmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ashmem.c 
> b/drivers/staging/android/ashmem.c
> index d66a64e42273..7854fd410efa 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -376,7 +376,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, 
> unsigned long addr,
>  
>  static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
>  {
> - static struct file_operations vmfile_fops;
> + static const struct file_operations vmfile_fops;
>   struct ashmem_area *asma = file->private_data;
>   int ret = 0;
>  

It's a bit rude to submit patches that you have not at the very least,
tried to build before sending it out to us, right?

Please always do so.

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging: android: ashmem: fixed a struct without const

2021-03-05 Thread nabil5352
Fixed a struct without const

Signed-off-by: nabil5352 
---
 drivers/staging/android/ashmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index d66a64e42273..7854fd410efa 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -376,7 +376,7 @@ ashmem_vmfile_get_unmapped_area(struct file *file, unsigned 
long addr,
 
 static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
 {
-   static struct file_operations vmfile_fops;
+   static const struct file_operations vmfile_fops;
struct ashmem_area *asma = file->private_data;
int ret = 0;
 
-- 
2.25.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel