* [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
@ 2023-08-11 2:49 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-08-11 2:49 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Christian Brauner <christianvanbrauner@gmail.com>
TO: Hugh Dickins <hughd@google.com>
CC: Christian Brauner <brauner@kernel.org>
CC: Jan Kara <jack@suse.cz>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.tmpfs
head: 3a3c2ca1fb82b27073db2ae1f3eb06820e8d6143
commit: 46170cc50828c33897d192668884d570b2c4e79b [15/19] xattr: simple_xattr_set() return old_xattr to be freed
:::::: branch date: 17 hours ago
:::::: commit date: 2 days ago
config: mips-randconfig-m031-20230809 (https://download.01.org/0day-ci/archive/20230811/202308111016.rximb8Ah-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230811/202308111016.rximb8Ah-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202308111016.rximb8Ah-lkp@intel.com/
smatch warnings:
mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +3611 mm/shmem.c
b09e0fa4b4ea66 Eric Paris 2011-05-24 3593
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3594 static int shmem_xattr_handler_set(const struct xattr_handler *handler,
39f60c1ccee72c Christian Brauner 2023-01-13 3595 struct mnt_idmap *idmap,
5930122683dff5 Al Viro 2016-05-27 3596 struct dentry *unused, struct inode *inode,
5930122683dff5 Al Viro 2016-05-27 3597 const char *name, const void *value,
5930122683dff5 Al Viro 2016-05-27 3598 size_t size, int flags)
b09e0fa4b4ea66 Eric Paris 2011-05-24 3599 {
5930122683dff5 Al Viro 2016-05-27 3600 struct shmem_inode_info *info = SHMEM_I(inode);
46170cc50828c3 Hugh Dickins 2023-08-08 3601 struct simple_xattr *old_xattr;
b09e0fa4b4ea66 Eric Paris 2011-05-24 3602
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3603 name = xattr_full_name(handler, name);
46170cc50828c3 Hugh Dickins 2023-08-08 3604 old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
46170cc50828c3 Hugh Dickins 2023-08-08 3605 if (!IS_ERR(old_xattr)) {
46170cc50828c3 Hugh Dickins 2023-08-08 3606 simple_xattr_free(old_xattr);
46170cc50828c3 Hugh Dickins 2023-08-08 3607 old_xattr = NULL;
36f05cab0a2c97 Jeff Layton 2022-09-09 3608 inode->i_ctime = current_time(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3609 inode_inc_iversion(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3610 }
46170cc50828c3 Hugh Dickins 2023-08-08 @3611 return PTR_ERR(old_xattr);
b09e0fa4b4ea66 Eric Paris 2011-05-24 3612 }
b09e0fa4b4ea66 Eric Paris 2011-05-24 3613
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread* [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
@ 2023-08-11 5:26 Dan Carpenter
2023-08-11 6:43 ` Hugh Dickins
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-08-11 5:26 UTC (permalink / raw)
To: oe-kbuild, Hugh Dickins
Cc: lkp, oe-kbuild-all, Christian Brauner, Christian Brauner,
Jan Kara
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.tmpfs
head: 3a3c2ca1fb82b27073db2ae1f3eb06820e8d6143
commit: 46170cc50828c33897d192668884d570b2c4e79b [15/19] xattr: simple_xattr_set() return old_xattr to be freed
config: mips-randconfig-m031-20230809 (https://download.01.org/0day-ci/archive/20230811/202308111016.rximb8Ah-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230811/202308111016.rximb8Ah-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202308111016.rximb8Ah-lkp@intel.com/
smatch warnings:
mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +3611 mm/shmem.c
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3594 static int shmem_xattr_handler_set(const struct xattr_handler *handler,
39f60c1ccee72c Christian Brauner 2023-01-13 3595 struct mnt_idmap *idmap,
5930122683dff5 Al Viro 2016-05-27 3596 struct dentry *unused, struct inode *inode,
5930122683dff5 Al Viro 2016-05-27 3597 const char *name, const void *value,
5930122683dff5 Al Viro 2016-05-27 3598 size_t size, int flags)
b09e0fa4b4ea66 Eric Paris 2011-05-24 3599 {
5930122683dff5 Al Viro 2016-05-27 3600 struct shmem_inode_info *info = SHMEM_I(inode);
46170cc50828c3 Hugh Dickins 2023-08-08 3601 struct simple_xattr *old_xattr;
b09e0fa4b4ea66 Eric Paris 2011-05-24 3602
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3603 name = xattr_full_name(handler, name);
46170cc50828c3 Hugh Dickins 2023-08-08 3604 old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
46170cc50828c3 Hugh Dickins 2023-08-08 3605 if (!IS_ERR(old_xattr)) {
46170cc50828c3 Hugh Dickins 2023-08-08 3606 simple_xattr_free(old_xattr);
46170cc50828c3 Hugh Dickins 2023-08-08 3607 old_xattr = NULL;
36f05cab0a2c97 Jeff Layton 2022-09-09 3608 inode->i_ctime = current_time(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3609 inode_inc_iversion(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3610 }
46170cc50828c3 Hugh Dickins 2023-08-08 @3611 return PTR_ERR(old_xattr);
This code is correct but it would be nicer to reverse the checking:
old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
if (IS_ERR(old_xattr))
return PTR_ERR(old_xattr);
simple_xattr_free(old_xattr);
inode->i_ctime = current_time(inode);
inode_inc_iversion(inode);
return 0;
b09e0fa4b4ea66 Eric Paris 2011-05-24 3612 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
2023-08-11 5:26 Dan Carpenter
@ 2023-08-11 6:43 ` Hugh Dickins
0 siblings, 0 replies; 4+ messages in thread
From: Hugh Dickins @ 2023-08-11 6:43 UTC (permalink / raw)
To: Dan Carpenter
Cc: oe-kbuild, Hugh Dickins, lkp, oe-kbuild-all, Christian Brauner,
Christian Brauner, Jan Kara
On Fri, 11 Aug 2023, Dan Carpenter wrote:
...
> smatch warnings:
> mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
...
> 46170cc50828c3 Hugh Dickins 2023-08-08 3604 old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
> 46170cc50828c3 Hugh Dickins 2023-08-08 3605 if (!IS_ERR(old_xattr)) {
> 46170cc50828c3 Hugh Dickins 2023-08-08 3606 simple_xattr_free(old_xattr);
> 46170cc50828c3 Hugh Dickins 2023-08-08 3607 old_xattr = NULL;
> 36f05cab0a2c97 Jeff Layton 2022-09-09 3608 inode->i_ctime = current_time(inode);
> 36f05cab0a2c97 Jeff Layton 2022-09-09 3609 inode_inc_iversion(inode);
> 36f05cab0a2c97 Jeff Layton 2022-09-09 3610 }
> 46170cc50828c3 Hugh Dickins 2023-08-08 @3611 return PTR_ERR(old_xattr);
>
> This code is correct but it would be nicer to reverse the checking:
>
> old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
> if (IS_ERR(old_xattr))
> return PTR_ERR(old_xattr);
>
> simple_xattr_free(old_xattr);
> inode->i_ctime = current_time(inode);
> inode_inc_iversion(inode);
>
> return 0;
Thanks, Dan, but I'm going to resist making any change here.
As you observe, the code is correct as is. And I did have a version
(unposted) which laid it out exactly as you have it there. But the
collisions between different branches of vfs.git (and subsequent mods
here in vfs.tmpfs) was such that I aimed to minimize the interference.
Please let's leave it as is: there is nothing wrong with PTR_ERR(NULL).
Hugh
^ permalink raw reply [flat|nested] 4+ messages in thread
* [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
@ 2023-08-11 21:15 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-08-11 21:15 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Christian Brauner <christianvanbrauner@gmail.com>
TO: Hugh Dickins <hughd@google.com>
CC: Christian Brauner <brauner@kernel.org>
CC: Jan Kara <jack@suse.cz>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.tmpfs
head: aa5b9178c01905d7691512b366cf2886dfe2680c
commit: 46170cc50828c33897d192668884d570b2c4e79b [15/19] xattr: simple_xattr_set() return old_xattr to be freed
:::::: branch date: 9 hours ago
:::::: commit date: 3 days ago
config: mips-randconfig-m031-20230809 (https://download.01.org/0day-ci/archive/20230812/202308120509.hkikGgvH-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230812/202308120509.hkikGgvH-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202308120509.hkikGgvH-lkp@intel.com/
smatch warnings:
mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +3611 mm/shmem.c
b09e0fa4b4ea66 Eric Paris 2011-05-24 3593
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3594 static int shmem_xattr_handler_set(const struct xattr_handler *handler,
39f60c1ccee72c Christian Brauner 2023-01-13 3595 struct mnt_idmap *idmap,
5930122683dff5 Al Viro 2016-05-27 3596 struct dentry *unused, struct inode *inode,
5930122683dff5 Al Viro 2016-05-27 3597 const char *name, const void *value,
5930122683dff5 Al Viro 2016-05-27 3598 size_t size, int flags)
b09e0fa4b4ea66 Eric Paris 2011-05-24 3599 {
5930122683dff5 Al Viro 2016-05-27 3600 struct shmem_inode_info *info = SHMEM_I(inode);
46170cc50828c3 Hugh Dickins 2023-08-08 3601 struct simple_xattr *old_xattr;
b09e0fa4b4ea66 Eric Paris 2011-05-24 3602
aa7c5241c380ad Andreas Gruenbacher 2015-12-02 3603 name = xattr_full_name(handler, name);
46170cc50828c3 Hugh Dickins 2023-08-08 3604 old_xattr = simple_xattr_set(&info->xattrs, name, value, size, flags);
46170cc50828c3 Hugh Dickins 2023-08-08 3605 if (!IS_ERR(old_xattr)) {
46170cc50828c3 Hugh Dickins 2023-08-08 3606 simple_xattr_free(old_xattr);
46170cc50828c3 Hugh Dickins 2023-08-08 3607 old_xattr = NULL;
36f05cab0a2c97 Jeff Layton 2022-09-09 3608 inode->i_ctime = current_time(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3609 inode_inc_iversion(inode);
36f05cab0a2c97 Jeff Layton 2022-09-09 3610 }
46170cc50828c3 Hugh Dickins 2023-08-08 @3611 return PTR_ERR(old_xattr);
b09e0fa4b4ea66 Eric Paris 2011-05-24 3612 }
b09e0fa4b4ea66 Eric Paris 2011-05-24 3613
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-11 21:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 2:49 [brauner-vfs:vfs.tmpfs 15/19] mm/shmem.c:3611 shmem_xattr_handler_set() warn: passing zero to 'PTR_ERR' kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2023-08-11 5:26 Dan Carpenter
2023-08-11 6:43 ` Hugh Dickins
2023-08-11 21:15 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.