@@ -69,7 +69,7 @@ bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface)
6969
7070/* channel helper functions. assumed that chan_lock is held by caller. */
7171
72- unsigned int
72+ int
7373cifs_ses_get_chan_index (struct cifs_ses * ses ,
7474 struct TCP_Server_Info * server )
7575{
@@ -85,14 +85,17 @@ cifs_ses_get_chan_index(struct cifs_ses *ses,
8585 cifs_dbg (VFS , "unable to get chan index for server: 0x%llx" ,
8686 server -> conn_id );
8787 WARN_ON (1 );
88- return 0 ;
88+ return CIFS_INVAL_CHAN_INDEX ;
8989}
9090
9191void
9292cifs_chan_set_in_reconnect (struct cifs_ses * ses ,
9393 struct TCP_Server_Info * server )
9494{
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 ;
9699
97100 ses -> chans [chan_index ].in_reconnect = true;
98101}
@@ -102,6 +105,8 @@ cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
102105 struct TCP_Server_Info * server )
103106{
104107 unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
108+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
109+ return ;
105110
106111 ses -> chans [chan_index ].in_reconnect = false;
107112}
@@ -111,6 +116,8 @@ cifs_chan_in_reconnect(struct cifs_ses *ses,
111116 struct TCP_Server_Info * server )
112117{
113118 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 */
114121
115122 return CIFS_CHAN_IN_RECONNECT (ses , chan_index );
116123}
@@ -120,6 +127,8 @@ cifs_chan_set_need_reconnect(struct cifs_ses *ses,
120127 struct TCP_Server_Info * server )
121128{
122129 unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
130+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
131+ return ;
123132
124133 set_bit (chan_index , & ses -> chans_need_reconnect );
125134 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,
131140 struct TCP_Server_Info * server )
132141{
133142 unsigned int chan_index = cifs_ses_get_chan_index (ses , server );
143+ if (chan_index == CIFS_INVAL_CHAN_INDEX )
144+ return ;
134145
135146 clear_bit (chan_index , & ses -> chans_need_reconnect );
136147 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,
142153 struct TCP_Server_Info * server )
143154{
144155 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 */
145158
146159 return CIFS_CHAN_NEEDS_RECONNECT (ses , chan_index );
147160}
@@ -151,6 +164,8 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
151164 struct TCP_Server_Info * server )
152165{
153166 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 */
154169
155170 return ses -> chans [chan_index ].iface &&
156171 ses -> chans [chan_index ].iface -> is_active ;
@@ -269,7 +284,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
269284
270285 spin_lock (& ses -> chan_lock );
271286 chan_index = cifs_ses_get_chan_index (ses , server );
272- if (! chan_index ) {
287+ if (chan_index == CIFS_INVAL_CHAN_INDEX ) {
273288 spin_unlock (& ses -> chan_lock );
274289 return 0 ;
275290 }
@@ -319,6 +334,11 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
319334
320335 spin_lock (& ses -> chan_lock );
321336 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+
322342 ses -> chans [chan_index ].iface = iface ;
323343
324344 /* No iface is found. if secondary chan, drop connection */
0 commit comments