@@ -69,7 +69,7 @@ bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface)
69
69
70
70
/* channel helper functions. assumed that chan_lock is held by caller. */
71
71
72
- unsigned int
72
+ int
73
73
cifs_ses_get_chan_index (struct cifs_ses * ses ,
74
74
struct TCP_Server_Info * server )
75
75
{
@@ -85,14 +85,17 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
85
85
cifs_dbg (VFS , "unable to get chan index for server: 0x%llx" ,
86
86
server -> conn_id );
87
87
WARN_ON (1 );
88
- return 0 ;
88
+ return CIFS_INVAL_CHAN_INDEX ;
89
89
}
90
90
91
91
void
92
92
cifs_chan_set_in_reconnect (struct cifs_ses * ses ,
93
93
struct TCP_Server_Info * server )
94
94
{
95
- unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
95
+ int chan_index = cifs_ses_get_chan_index (ses , server );
96
+
97
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
98
+ return ;
96
99
97
100
ses -> chans [chan_index ].in_reconnect = true;
98
101
}
@@ -102,6 +105,8 @@ cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
102
105
struct TCP_Server_Info * server )
103
106
{
104
107
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
108
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
109
+ return ;
105
110
106
111
ses -> chans [chan_index ].in_reconnect = false;
107
112
}
@@ -111,6 +116,8 @@ cifs_chan_in_reconnect(struct cifs_ses *ses,
111
116
struct TCP_Server_Info * server )
112
117
{
113
118
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
119
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
120
+ return true; /* err on the safer side */
114
121
115
122
return CIFS_CHAN_IN_RECONNECT (ses , chan_index );
116
123
}
@@ -120,6 +127,8 @@ cifs_chan_set_need_reconnect(struct cifs_ses *ses,
120
127
struct TCP_Server_Info * server )
121
128
{
122
129
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
130
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
131
+ return ;
123
132
124
133
set_bit (chan_index , & ses -> chans_need_reconnect );
125
134
cifs_dbg (FYI , "Set reconnect bitmask for chan %u; now 0x%lx\n" ,
@@ -131,6 +140,8 @@ cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
131
140
struct TCP_Server_Info * server )
132
141
{
133
142
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
143
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
144
+ return ;
134
145
135
146
clear_bit (chan_index , & ses -> chans_need_reconnect );
136
147
cifs_dbg (FYI , "Cleared reconnect bitmask for chan %u; now 0x%lx\n" ,
@@ -142,6 +153,8 @@ cifs_chan_needs_reconnect(struct cifs_ses *ses,
142
153
struct TCP_Server_Info * server )
143
154
{
144
155
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
156
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
157
+ return true; /* err on the safer side */
145
158
146
159
return CIFS_CHAN_NEEDS_RECONNECT (ses , chan_index );
147
160
}
@@ -151,6 +164,8 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
151
164
struct TCP_Server_Info * server )
152
165
{
153
166
unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
167
+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
168
+ return true; /* err on the safer side */
154
169
155
170
return ses -> chans [chan_index ].iface &&
156
171
ses -> chans [chan_index ].iface -> is_active ;
@@ -269,7 +284,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
269
284
270
285
spin_lock (& ses -> chan_lock );
271
286
chan_index = cifs_ses_get_chan_index (ses , server );
272
- if (! chan_index ) {
287
+ if (chan_index == CIFS_INVAL_CHAN_INDEX ) {
273
288
spin_unlock (& ses -> chan_lock );
274
289
return 0 ;
275
290
}
@@ -319,6 +334,11 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
319
334
320
335
spin_lock (& ses -> chan_lock );
321
336
chan_index = cifs_ses_get_chan_index (ses , server );
337
+ if (chan_index == CIFS_INVAL_CHAN_INDEX ) {
338
+ spin_unlock (& ses -> chan_lock );
339
+ return 0 ;
340
+ }
341
+
322
342
ses -> chans [chan_index ].iface = iface ;
323
343
324
344
/* No iface is found. if secondary chan, drop connection */
0 commit comments