diff options
author | Su Hui <suhui@nfschina.com> | 2024-08-08 20:23:32 +0800 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2024-08-15 15:32:30 -0500 |
commit | 74c2ab6d653b4c2354df65a7f7f2df1925a40a51 (patch) | |
tree | 7023b5c25ac30814e680d9a8863f4bac9bce535e /fs | |
parent | 7c626ce4bae1ac14f60076d00eafe71af30450ba (diff) | |
download | linux-stable-74c2ab6d653b4c2354df65a7f7f2df1925a40a51.tar.gz linux-stable-74c2ab6d653b4c2354df65a7f7f2df1925a40a51.tar.bz2 linux-stable-74c2ab6d653b4c2354df65a7f7f2df1925a40a51.zip |
smb/client: avoid possible NULL dereference in cifs_free_subrequest()
Clang static checker (scan-build) warning:
cifsglob.h:line 890, column 3
Access to field 'ops' results in a dereference of a null pointer.
Commit 519be989717c ("cifs: Add a tracepoint to track credits involved in
R/W requests") adds a check for 'rdata->server', and let clang throw this
warning about NULL dereference.
When 'rdata->credits.value != 0 && rdata->server == NULL' happens,
add_credits_and_wake_if() will call rdata->server->ops->add_credits().
This will cause NULL dereference problem. Add a check for 'rdata->server'
to avoid NULL dereference.
Cc: stable@vger.kernel.org
Fixes: 69c3c023af25 ("cifs: Implement netfslib hooks")
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/smb/client/file.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index b2405dd4d4d4..45459af5044d 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -315,7 +315,7 @@ static void cifs_free_subrequest(struct netfs_io_subrequest *subreq) #endif } - if (rdata->credits.value != 0) + if (rdata->credits.value != 0) { trace_smb3_rw_credits(rdata->rreq->debug_id, rdata->subreq.debug_index, rdata->credits.value, @@ -323,8 +323,12 @@ static void cifs_free_subrequest(struct netfs_io_subrequest *subreq) rdata->server ? rdata->server->in_flight : 0, -rdata->credits.value, cifs_trace_rw_credits_free_subreq); + if (rdata->server) + add_credits_and_wake_if(rdata->server, &rdata->credits, 0); + else + rdata->credits.value = 0; + } - add_credits_and_wake_if(rdata->server, &rdata->credits, 0); if (rdata->have_xid) free_xid(rdata->xid); } |