CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Shyam Prasad N <[email protected]>
CC: Steve French <[email protected]>

tree:   git://git.samba.org/sfrench/cifs-2.6.git tmp-mchan-branch
head:   5dcedd487447680668c095add4b24432a06b2644
commit: 81b88cd97eb7df45d283a92b56603f6e433a69b5 [14/21] cifs: check reconnects 
for channels of active tcons too
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: x86_64-randconfig-c022-20220117 
(https://download.01.org/0day-ci/archive/20220120/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Julia Lawall <[email protected]>


cocci warnings: (new ones prefixed by >>)
>> fs/cifs/smb2pdu.c:3869:17-20: ERROR: invalid reference to the index variable 
>> of the iterator on line 3809

vim +3869 fs/cifs/smb2pdu.c

9094fad1ed90ca Pavel Shilovsky  2012-07-12  3784  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3785  void 
smb2_reconnect_server(struct work_struct *work)
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3786  {
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3787        struct TCP_Server_Info 
*server = container_of(work,
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3788                                
        struct TCP_Server_Info, reconnect.work);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3789        struct TCP_Server_Info 
*pserver;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3790        struct cifs_ses *ses, 
*ses2;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3791        struct cifs_tcon *tcon, 
*tcon2;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3792        struct list_head 
tmp_list, tmp_ses_list;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3793        bool tcon_exist = 
false, ses_exist = false;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3794        bool tcon_selected = 
false, ses_selected = false;
18ea43113f5b74 Germano Percossi 2017-04-07  3795        int rc;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3796        bool resched = false;
18ea43113f5b74 Germano Percossi 2017-04-07  3797  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3798        /* If server is a 
channel, select the primary channel */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3799        pserver = 
CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3800  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3801        /* Prevent simultaneous 
reconnects that can corrupt tcon->rlist list */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3802        
mutex_lock(&pserver->reconnect_mutex);
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3803  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3804        
INIT_LIST_HEAD(&tmp_list);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3805        
INIT_LIST_HEAD(&tmp_ses_list);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3806        cifs_dbg(FYI, 
"Reconnecting tcons and channels\n");
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3807  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3808        
spin_lock(&cifs_tcp_ses_lock);
81b88cd97eb7df Shyam Prasad N   2021-10-30 @3809        
list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
81b88cd97eb7df Shyam Prasad N   2021-10-30  3810  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3811                tcon_selected = 
ses_selected = false;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3812  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3813                
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
96a988ffeb90db Pavel Shilovsky  2016-11-29  3814                        if 
(tcon->need_reconnect || tcon->need_reopen_files) {
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3815                                
tcon->tc_count++;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3816                                
list_add_tail(&tcon->rlist, &tmp_list);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3817                                
tcon_selected = tcon_exist = true;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3818                        }
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3819                }
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3820                /*
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3821                 * IPC has the 
same lifetime as its session and uses its
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3822                 * refcount.
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3823                 */
b327a717e50698 Aurelien Aptel   2018-01-24  3824                if 
(ses->tcon_ipc && ses->tcon_ipc->need_reconnect) {
b327a717e50698 Aurelien Aptel   2018-01-24  3825                        
list_add_tail(&ses->tcon_ipc->rlist, &tmp_list);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3826                        
tcon_selected = tcon_exist = true;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3827                        
ses->ses_count++;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3828                }
81b88cd97eb7df Shyam Prasad N   2021-10-30  3829                /*
81b88cd97eb7df Shyam Prasad N   2021-10-30  3830                 * handle the 
case where channel needs to reconnect
81b88cd97eb7df Shyam Prasad N   2021-10-30  3831                 * binding 
session, but tcon is healthy (some other channel
81b88cd97eb7df Shyam Prasad N   2021-10-30  3832                 * is active)
81b88cd97eb7df Shyam Prasad N   2021-10-30  3833                 */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3834                if 
(!tcon_selected && cifs_chan_needs_reconnect(ses, server)) {
81b88cd97eb7df Shyam Prasad N   2021-10-30  3835                        
list_add_tail(&ses->rlist, &tmp_ses_list);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3836                        
ses_selected = ses_exist = true;
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3837                        
ses->ses_count++;
b327a717e50698 Aurelien Aptel   2018-01-24  3838                }
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3839        }
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3840        /*
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3841         * Get the reference to 
server struct to be sure that the last call of
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3842         * cifs_put_tcon() in 
the loop below won't release the server pointer.
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3843         */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3844        if (tcon_exist || 
ses_exist)
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3845                
server->srv_count++;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3846  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3847        
spin_unlock(&cifs_tcp_ses_lock);
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3848  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3849        
list_for_each_entry_safe(tcon, tcon2, &tmp_list, rlist) {
352d96f3acc6e0 Aurelien Aptel   2020-05-31  3850                rc = 
smb2_reconnect(SMB2_INTERNAL_CMD, tcon, server);
18ea43113f5b74 Germano Percossi 2017-04-07  3851                if (!rc)
96a988ffeb90db Pavel Shilovsky  2016-11-29  3852                        
cifs_reopen_persistent_handles(tcon);
18ea43113f5b74 Germano Percossi 2017-04-07  3853                else
18ea43113f5b74 Germano Percossi 2017-04-07  3854                        resched 
= true;
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3855                
list_del_init(&tcon->rlist);
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3856                if (tcon->ipc)
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3857                        
cifs_put_smb_ses(tcon->ses);
0ff2b018b02f89 Ronnie Sahlberg  2019-06-05  3858                else
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3859                        
cifs_put_tcon(tcon);
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3860        }
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3861  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3862        if (!ses_exist)
81b88cd97eb7df Shyam Prasad N   2021-10-30  3863                goto done;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3864  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3865        /* allocate a dummy 
tcon struct used for reconnect */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3866        tcon = 
kzalloc(sizeof(struct cifs_tcon), GFP_KERNEL);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3867        if (!tcon) {
81b88cd97eb7df Shyam Prasad N   2021-10-30  3868                resched = true;
81b88cd97eb7df Shyam Prasad N   2021-10-30 @3869                
list_del_init(&ses->rlist);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3870                
cifs_put_smb_ses(ses);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3871                goto done;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3872        }
81b88cd97eb7df Shyam Prasad N   2021-10-30  3873  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3874        tcon->tidStatus = 
CifsGood;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3875        tcon->retry = false;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3876        tcon->need_reconnect = 
false;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3877  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3878        /* now reconnect 
sessions for necessary channels */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3879        
list_for_each_entry_safe(ses, ses2, &tmp_ses_list, rlist) {
81b88cd97eb7df Shyam Prasad N   2021-10-30  3880                tcon->ses = ses;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3881                rc = 
smb2_reconnect(SMB2_INTERNAL_CMD, tcon, server);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3882                if (rc)
81b88cd97eb7df Shyam Prasad N   2021-10-30  3883                        resched 
= true;
81b88cd97eb7df Shyam Prasad N   2021-10-30  3884                
list_del_init(&ses->rlist);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3885                
cifs_put_smb_ses(ses);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3886        }
81b88cd97eb7df Shyam Prasad N   2021-10-30  3887        kfree(tcon);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3888  
81b88cd97eb7df Shyam Prasad N   2021-10-30  3889  done:
81b88cd97eb7df Shyam Prasad N   2021-10-30  3890        cifs_dbg(FYI, 
"Reconnecting tcons and channels finished\n");
18ea43113f5b74 Germano Percossi 2017-04-07  3891        if (resched)
18ea43113f5b74 Germano Percossi 2017-04-07  3892                
queue_delayed_work(cifsiod_wq, &server->reconnect, 2 * HZ);
81b88cd97eb7df Shyam Prasad N   2021-10-30  3893        
mutex_unlock(&pserver->reconnect_mutex);
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3894  
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3895        /* now we can safely 
release srv struct */
81b88cd97eb7df Shyam Prasad N   2021-10-30  3896        if (tcon_exist || 
ses_exist)
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3897                
cifs_put_tcp_session(server, 1);
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3898  }
53e0e11efe9289 Pavel Shilovsky  2016-11-04  3899  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to