fs:cifs: convert from atomic_t to refcount_t on tlink->tl_count
Subsystems (2)
PATCH 1/1 fs:cifs: convert from atomic_t to refcount_t on tlink->tl_count
From: chiminghao <[email protected]>
use refcount_t instead of atomic_t
which prevents reference counter overflows.
--- fs/cifs/cifsglob.h | 4 ++-- fs/cifs/connect.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +2 -2
@@ -8,7 +8,7 @@*/ #ifndef _CIFS_GLOB_H#define _CIFS_GLOB_H - +#include <linux/refcount.h> #include <linux/in.h> #include <linux/in6.h> #include <linux/inet.h>
@@ -1115,7 +1115,7 @@ struct tcon_link {#define TCON_LINK_PENDING 1#define TCON_LINK_IN_TREE 2unsigned long tl_time; -atomic_t tl_count; +refcount_t tl_count;struct cifs_tcon *tl_tcon; };
fs/cifs/connect.c +1 -1
@@ -2318,7 +2318,7 @@ cifs_put_tlink(struct tcon_link *tlink)if (!tlink ||IS_ERR (tlink))return ; -if (!atomic_dec_and_test (&tlink->tl_count) || +if (!refcount_dec_and_test (&tlink->tl_count) ||test_bit (TCON_LINK_IN_TREE , &tlink->tl_flags)) { tlink->tl_time = jiffies;return ;
Signature · 1 line
2.25.1
merged into cifs-2.6.git for-next pending testing
Quoted 51 lines · On Fri, Nov 12, 2021 at 3:32 AM <[email protected]> wrote:
From: chiminghao <[email protected]>
use
refcount_tinstead ofatomic_t
which prevents reference counter overflows.Reported-by Zeal Robot <[email protected]>Signed-off-by chiminghao <[email protected]>--- fs/cifs/cifsglob.h | 4 ++-- fs/cifs/connect.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)fs/cifs/cifsglob.h +2
-2@@ -8,7 +8,7 @@*/ #ifndef _CIFS_GLOB_H#define _CIFS_GLOB_H - +#include <linux/refcount.h> #include <linux/in.h> #include <linux/in6.h> #include <linux/inet.h> @@ -1115,7 +1115,7 @@ struct tcon_link {#define TCON_LINK_PENDING 1#define TCON_LINK_IN_TREE 2unsigned long tl_time; -atomic_t tl_count; +refcount_t tl_count;struct cifs_tcon *tl_tcon; };fs/cifs/connect.c +1
-2@@ -2318,7 +2318,7 @@ cifs_put_tlink(struct tcon_link *tlink)if (!tlink ||IS_ERR (tlink))return ; -if (!atomic_dec_and_test (&tlink->tl_count) || +if (!refcount_dec_and_test (&tlink->tl_count) ||test_bit (TCON_LINK_IN_TREE , &tlink->tl_flags)) { tlink->tl_time = jiffies;return ; --2.25.1
Signature · 3 lines
Thanks, Steve
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on v5.16-rc1 next-20211115]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/fs-cifs-convert-from-atomic_t-to-refcount_t-on-tlink-tl_count/20211112-173127 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: i386-debian-10.3 (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/8d0f81fa94784bab585209f6cea84ea63a4a37ba git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review cgel-zte-gmail-com/fs-cifs-convert-from-atomic_t-to-refcount_t-on-tlink-tl_count/20211112-173127 git checkout 8d0f81fa94784bab585209f6cea84ea63a4a37ba # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from fs/cifs/cifsfs.c:33:
fs/cifs/cifsglob.h: In function 'cifs_get_tlink':
>> fs/cifs/cifsglob.h:1156:14: error: passing argument 1 of 'atomic_inc' from incompatible pointer type [-Werror=incompatible-pointer-types]
1156 | atomic_inc(&tlink->tl_count);
| ^~~~~~~~~~~~~~~~
| |
| refcount_t * {aka struct refcount_struct *}
In file included from include/linux/atomic.h:82,
from include/linux/cpumask.h:13,
from arch/x86/include/asm/cpumask.h:5,
from arch/x86/include/asm/msr.h:11,
from arch/x86/include/asm/processor.h:22,
from arch/x86/include/asm/timex.h:5,
from include/linux/timex.h:65,
from include/linux/time32.h:13,
from include/linux/time.h:60,
from include/linux/stat.h:19,
from include/linux/module.h:13,
from fs/cifs/cifsfs.c:13:
include/linux/atomic/atomic-instrumented.h:179:22: note: expected 'atomic_t *' {aka 'struct <anonymous> *'} but argument is of type 'refcount_t *' {aka 'struct refcount_struct *'}
179 | atomic_inc(atomic_t *v)
| ~~~~~~~~~~^ cc1: some warnings being treated as errors
--
In file included from fs/cifs/connect.c:36:
fs/cifs/cifsglob.h: In function 'cifs_get_tlink':
>> fs/cifs/cifsglob.h:1156:14: error: passing argument 1 of 'atomic_inc' from incompatible pointer type [-Werror=incompatible-pointer-types]
1156 | atomic_inc(&tlink->tl_count);
| ^~~~~~~~~~~~~~~~
| |
| refcount_t * {aka struct refcount_struct *}
In file included from include/linux/atomic.h:82,
from include/linux/cpumask.h:13,
from arch/x86/include/asm/cpumask.h:5,
from arch/x86/include/asm/msr.h:11,
from arch/x86/include/asm/processor.h:22,
from arch/x86/include/asm/cpufeature.h:5,
from arch/x86/include/asm/thread_info.h:53,
from include/linux/thread_info.h:60,
from arch/x86/include/asm/preempt.h:7,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs/cifs/connect.c:8:
include/linux/atomic/atomic-instrumented.h:179:22: note: expected 'atomic_t *' {aka 'struct <anonymous> *'} but argument is of type 'refcount_t *' {aka 'struct refcount_struct *'}
179 | atomic_inc(atomic_t *v)
| ~~~~~~~~~~^
fs/cifs/connect.c: In function 'cifs_prune_tlinks':
>> fs/cifs/connect.c:4053:19: error: passing argument 1 of 'atomic_read' from incompatible pointer type [-Werror=incompatible-pointer-types]
4053 | atomic_read(&tlink->tl_count) != 0 ||
| ^~~~~~~~~~~~~~~~
| |
| refcount_t * {aka struct refcount_struct *}
In file included from include/linux/atomic.h:82,
from include/linux/cpumask.h:13,
from arch/x86/include/asm/cpumask.h:5,
from arch/x86/include/asm/msr.h:11,
from arch/x86/include/asm/processor.h:22,
from arch/x86/include/asm/cpufeature.h:5,
from arch/x86/include/asm/thread_info.h:53,
from include/linux/thread_info.h:60,
from arch/x86/include/asm/preempt.h:7,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from fs/cifs/connect.c:8: include/linux/atomic/atomic-instrumented.h:25:29: note: expected 'const atomic_t *' {aka 'const struct <anonymous> *'} but argument is of type 'refcount_t *' {aka 'struct refcount_struct *'}
25 | atomic_read(const atomic_t *v)
| ~~~~~~~~~~~~~~~~^
cc1: some warnings being treated as errors
vim +/atomic_inc +1156 fs/cifs/cifsglob.h
7ffec372458d16 Jeff Layton 2010-09-29 1151
13cfb7334eb6fd Jeff Layton 2010-09-29 1152 static inline struct tcon_link *
13cfb7334eb6fd Jeff Layton 2010-09-29 1153 cifs_get_tlink(struct tcon_link *tlink)
13cfb7334eb6fd Jeff Layton 2010-09-29 1154 {
9d002df492b14c Jeff Layton 2010-10-06 1155 if (tlink && !IS_ERR(tlink))
9d002df492b14c Jeff Layton 2010-10-06 @1156 atomic_inc(&tlink->tl_count);
13cfb7334eb6fd Jeff Layton 2010-09-29 1157 return tlink;
13cfb7334eb6fd Jeff Layton 2010-09-29 1158 }13cfb7334eb6fd Jeff Layton 2010-09-29 1159
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on cifs/for-next]
[also build test ERROR on v5.16-rc1 next-20211115]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/cgel-zte-gmail-com/fs-cifs-convert-from-atomic_t-to-refcount_t-on-tlink-tl_count/20211112-173127 base: git://git.samba.org/sfrench/cifs-2.6.git for-next config: hexagon-randconfig-r041-20211115 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project fbe72e41b99dc7994daac300d208a955be3e4a0a)
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/8d0f81fa94784bab585209f6cea84ea63a4a37ba
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/fs-cifs-convert-from-atomic_t-to-refcount_t-on-tlink-tl_count/20211112-173127 git checkout 8d0f81fa94784bab585209f6cea84ea63a4a37ba
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=hexagon
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from fs/cifs/cifsacl.c:18:
>> fs/cifs/cifsglob.h:1156:14: error: incompatible pointer types passing 'refcount_t *' (aka 'struct refcount_struct *') to parameter of type 'atomic_t *' [-Werror,-Wincompatible-pointer-types]
atomic_inc(&tlink->tl_count);
^~~~~~~~~~~~~~~~
include/linux/atomic/atomic-instrumented.h:179:22: note: passing argument to parameter 'v' here
atomic_inc(atomic_t *v)
^
1 error generated.
--
In file included from fs/cifs/ioctl.c:17:
>> fs/cifs/cifsglob.h:1156:14: error: incompatible pointer types passing 'refcount_t *' (aka 'struct refcount_struct *') to parameter of type 'atomic_t *' [-Werror,-Wincompatible-pointer-types]
atomic_inc(&tlink->tl_count);
^~~~~~~~~~~~~~~~
include/linux/atomic/atomic-instrumented.h:179:22: note: passing argument to parameter 'v' here
atomic_inc(atomic_t *v)
^
fs/cifs/ioctl.c:324:10: warning: variable 'caps' set but not used [-Wunused-but-set-variable]
__u64 caps;
^
1 warning and 1 error generated.
--
In file included from fs/cifs/connect.c:36:
>> fs/cifs/cifsglob.h:1156:14: error: incompatible pointer types passing 'refcount_t *' (aka 'struct refcount_struct *') to parameter of type 'atomic_t *' [-Werror,-Wincompatible-pointer-types]
atomic_inc(&tlink->tl_count);
^~~~~~~~~~~~~~~~
include/linux/atomic/atomic-instrumented.h:179:22: note: passing argument to parameter 'v' here
atomic_inc(atomic_t *v)
^
fs/cifs/connect.c:3008:14: error: no member named 'fscache' in 'struct cifs_tcon'
if (!tcon->fscache)
~~~~ ^
>> fs/cifs/connect.c:4053:19: error: incompatible pointer types passing 'refcount_t *' (aka 'struct refcount_struct *') to parameter of type 'const atomic_t *' [-Werror,-Wincompatible-pointer-types]
atomic_read(&tlink->tl_count) != 0 ||
^~~~~~~~~~~~~~~~
include/linux/atomic/atomic-instrumented.h:25:29: note: passing argument to parameter 'v' here
atomic_read(const atomic_t *v)
^3 errors generated.
vim +1156 fs/cifs/cifsglob.h
7ffec372458d16 Jeff Layton 2010-09-29 1151
13cfb7334eb6fd Jeff Layton 2010-09-29 1152 static inline struct tcon_link *
13cfb7334eb6fd Jeff Layton 2010-09-29 1153 cifs_get_tlink(struct tcon_link *tlink)
13cfb7334eb6fd Jeff Layton 2010-09-29 1154 {
9d002df492b14c Jeff Layton 2010-10-06 1155 if (tlink && !IS_ERR(tlink))
9d002df492b14c Jeff Layton 2010-10-06 @1156 atomic_inc(&tlink->tl_count);
13cfb7334eb6fd Jeff Layton 2010-09-29 1157 return tlink;
13cfb7334eb6fd Jeff Layton 2010-09-29 1158 }13cfb7334eb6fd Jeff Layton 2010-09-29 1159
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org