Commit 193cc89e authored by Steve French's avatar Steve French

cifs: fix potential null pointer use in destroy_workqueue in init_cifs error path

Dan Carpenter reported a Smack static checker warning:
   fs/smb/client/cifsfs.c:1981 init_cifs()
   error: we previously assumed 'serverclose_wq' could be null (see line 1895)

The patch which introduced the serverclose workqueue used the wrong
oredering in error paths in init_cifs() for freeing it on errors.

Fixes: 173217bd ("smb3: retrying on failed server close")
Cc: stable@vger.kernel.org
Cc: Ritvik Budhiraja <rbudhiraja@microsoft.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: default avatarDavid Howells <dhowell@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 33c9de29
...@@ -1894,12 +1894,12 @@ init_cifs(void) ...@@ -1894,12 +1894,12 @@ init_cifs(void)
WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
if (!serverclose_wq) { if (!serverclose_wq) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_destroy_serverclose_wq; goto out_destroy_deferredclose_wq;
} }
rc = cifs_init_inodecache(); rc = cifs_init_inodecache();
if (rc) if (rc)
goto out_destroy_deferredclose_wq; goto out_destroy_serverclose_wq;
rc = cifs_init_netfs(); rc = cifs_init_netfs();
if (rc) if (rc)
...@@ -1967,6 +1967,8 @@ init_cifs(void) ...@@ -1967,6 +1967,8 @@ init_cifs(void)
cifs_destroy_netfs(); cifs_destroy_netfs();
out_destroy_inodecache: out_destroy_inodecache:
cifs_destroy_inodecache(); cifs_destroy_inodecache();
out_destroy_serverclose_wq:
destroy_workqueue(serverclose_wq);
out_destroy_deferredclose_wq: out_destroy_deferredclose_wq:
destroy_workqueue(deferredclose_wq); destroy_workqueue(deferredclose_wq);
out_destroy_cifsoplockd_wq: out_destroy_cifsoplockd_wq:
...@@ -1977,8 +1979,6 @@ init_cifs(void) ...@@ -1977,8 +1979,6 @@ init_cifs(void)
destroy_workqueue(decrypt_wq); destroy_workqueue(decrypt_wq);
out_destroy_cifsiod_wq: out_destroy_cifsiod_wq:
destroy_workqueue(cifsiod_wq); destroy_workqueue(cifsiod_wq);
out_destroy_serverclose_wq:
destroy_workqueue(serverclose_wq);
out_clean_proc: out_clean_proc:
cifs_proc_clean(); cifs_proc_clean();
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment