From: cgel.zte@gmail.com
To: sfrench@samba.org
Cc: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org,
linux-kernel@vger.kernel.org, chiminghao <chi.minghao@zte.com.cn>,
Zeal Robot <zealci@zte.com.cm>
Subject: [PATCH] fs:cifs: convert from atomic_t to refcount_t on tlink->tl_count
Date: Fri, 12 Nov 2021 09:30:51 +0000 [thread overview]
Message-ID: <20211112093051.9366-1-chi.minghao@zte.com.cn> (raw)
From: chiminghao <chi.minghao@zte.com.cn>
use refcount_t instead of atomic_t
which prevents reference counter overflows.
Reported-by: Zeal Robot <zealci@zte.com.cm>
Signed-off-by: chiminghao <chi.minghao@zte.com.cn>
---
fs/cifs/cifsglob.h | 4 ++--
fs/cifs/connect.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 41e97df4e0e5..a8edaada0fea 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -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 2
unsigned long tl_time;
- atomic_t tl_count;
+ refcount_t tl_count;
struct cifs_tcon *tl_tcon;
};
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 9637465d23db..4aad8c9acf2e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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
next reply other threads:[~2021-11-12 9:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 9:30 cgel.zte [this message]
2021-11-15 5:13 ` Steve French
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211112093051.9366-1-chi.minghao@zte.com.cn \
--to=cgel.zte@gmail.com \
--cc=chi.minghao@zte.com.cn \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
--cc=zealci@zte.com.cm \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®