lkml.org 
[lkml]   [2021]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH linux-next] cifs: fix type of chans_need_reconnect on 32bit
Date
commit 69f98828728f ("cifs: get rid of binding_chan and use
chans_need_reconnect instead") uses chans_need_reconnect with test_bit
which expects volatile unsigned long but the field is size_t.

There are only 16 channels and the variable is assiggned into unsigned
long and plain int locals so there is clearly no need for the 64bit
precision. Also it could fail quite badly on 32bit bigendian.

Fixes: 69f98828728f ("cifs: get rid of binding_chan and use chans_need_reconnect instead")
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
fs/cifs/cifs_debug.c | 2 +-
fs/cifs/cifsfs.c | 2 +-
fs/cifs/cifsglob.h | 6 +++---
fs/cifs/sess.c | 6 +++---
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index 15635b45af59..9b0f35b7746c 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -425,7 +425,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
from_kuid(&init_user_ns, ses->cred_uid));

if (ses->chan_count > 1) {
- seq_printf(m, "\n\n\tExtra Channels: %zu ",
+ seq_printf(m, "\n\n\tExtra Channels: %lu ",
ses->chan_count-1);
for (j = 1; j < ses->chan_count; j++)
cifs_dump_channel(m, j, &ses->chans[j]);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 2ffcb29d5c8f..c4baccc14fde 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -684,7 +684,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
}

if (tcon->ses->chan_max > 1)
- seq_printf(s, ",multichannel,max_channels=%zu",
+ seq_printf(s, ",multichannel,max_channels=%lu",
tcon->ses->chan_max);

if (tcon->use_witness)
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 8fea2ddd2bd7..96499fc70c82 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -955,8 +955,8 @@ struct cifs_ses {
test_bit((index), &(ses)->chans_need_reconnect)

struct cifs_chan chans[CIFS_MAX_CHANNELS];
- size_t chan_count;
- size_t chan_max;
+ unsigned long chan_count;
+ unsigned long chan_max;
atomic_t chan_seq; /* round robin state */
/*
* chans_need_reconnect is a bitmap indicating which of the channels
@@ -968,7 +968,7 @@ struct cifs_ses {
* enable the sessions on top to continue to live till any
* of the channels below are active.
*/
- size_t chans_need_reconnect;
+ unsigned long chans_need_reconnect;
};

static inline bool
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index 1721a3b24694..9eded8151ae7 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -94,7 +94,7 @@ void
cifs_chan_set_need_reconnect(struct cifs_ses *ses,
struct TCP_Server_Info *server)
{
- size_t chan_index = cifs_ses_get_chan_index(ses, server);
+ unsigned long chan_index = cifs_ses_get_chan_index(ses, server);
set_bit(chan_index, &ses->chans_need_reconnect);
cifs_dbg(FYI, "Set reconnect bitmask for chan %lu; now 0x%lx\n",
chan_index, ses->chans_need_reconnect);
@@ -104,7 +104,7 @@ void
cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
struct TCP_Server_Info *server)
{
- size_t chan_index = cifs_ses_get_chan_index(ses, server);
+ unsigned long chan_index = cifs_ses_get_chan_index(ses, server);
clear_bit(chan_index, &ses->chans_need_reconnect);
cifs_dbg(FYI, "Cleared reconnect bitmask for chan %lu; now 0x%lx\n",
chan_index, ses->chans_need_reconnect);
@@ -131,7 +131,7 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)

if (left <= 0) {
cifs_dbg(FYI,
- "ses already at max_channels (%zu), nothing to open\n",
+ "ses already at max_channels (%lu), nothing to open\n",
ses->chan_max);
return 0;
}
--
2.26.2
\
 
 \ /
  Last update: 2021-06-07 11:31    [W:0.030 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site