diff mbox series

cifs: avoid NULL pointer dereference in dbg call

Message ID 20250319123110.21814-1-adiupina@astralinux.ru (mailing list archive)
State New, archived
Headers show
Series cifs: avoid NULL pointer dereference in dbg call | expand

Commit Message

Alexandra Diupina March 19, 2025, 12:31 p.m. UTC
cifs_server_dbg() implies server to be non-NULL so
move call under condition to avoid NULL pointer dereference.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e79b0332ae06 ("cifs: ignore cached share root handle closing errors")
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
---
 fs/smb/client/smb2misc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Fedor Pchelkin March 19, 2025, 1:20 p.m. UTC | #1
On Wed, 19. Mar 15:31, Alexandra Diupina wrote:
> diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
> index f3c4b70b77b9..c02aab58aade 100644
> --- a/fs/smb/client/smb2misc.c
> +++ b/fs/smb/client/smb2misc.c
> @@ -816,11 +816,12 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
>  		WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
>  		spin_unlock(&cifs_tcp_ses_lock);
>  
> -		if (tcon->ses)
> +		if (tcon->ses) {
>  			server = tcon->ses->server;
> -
> -		cifs_server_dbg(FYI, "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
> -				tcon->tid, persistent_fid, volatile_fid);
> +			cifs_server_dbg(FYI,
> +							"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
> +							tcon->tid, persistent_fid, volatile_fid);
> +		}

Something is wrong with the indentation. Usually scripts/checkpatch.pl
can give some feedback on this, too.

CHECK: Alignment should match open parenthesis
#32: FILE: fs/smb/client/smb2misc.c:822:
+			cifs_server_dbg(FYI,
+							"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",

>  
>  		return 0;
>  	}
> -- 
> 2.30.2
Alexandra Diupina March 19, 2025, 2:19 p.m. UTC | #2
19/03/25 16:20, Fedor Pchelkin пишет:
> On Wed, 19. Mar 15:31, Alexandra Diupina wrote:
>> diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
>> index f3c4b70b77b9..c02aab58aade 100644
>> --- a/fs/smb/client/smb2misc.c
>> +++ b/fs/smb/client/smb2misc.c
>> @@ -816,11 +816,12 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
>>   		WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
>>   		spin_unlock(&cifs_tcp_ses_lock);
>>   
>> -		if (tcon->ses)
>> +		if (tcon->ses) {
>>   			server = tcon->ses->server;
>> -
>> -		cifs_server_dbg(FYI, "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
>> -				tcon->tid, persistent_fid, volatile_fid);
>> +			cifs_server_dbg(FYI,
>> +							"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
>> +							tcon->tid, persistent_fid, volatile_fid);
>> +		}
> Something is wrong with the indentation. Usually scripts/checkpatch.pl
> can give some feedback on this, too.
>
> CHECK: Alignment should match open parenthesis
> #32: FILE: fs/smb/client/smb2misc.c:822:
> +			cifs_server_dbg(FYI,
> +							"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",

In the *.patch file, everything was fine with indents,
so the checkpatch.pl script completed without errors.
But when sending, the indents got corrupted for some
reason. I'll send the second version
>
>>   
>>   		return 0;
>>   	}
>> -- 
>> 2.30.2
Steve French March 19, 2025, 7:30 p.m. UTC | #3
I don't mind if you also send patches as attachments (or with pointer
to git or github commit link), especially if your email is corrupting
whitespace

On Wed, Mar 19, 2025 at 9:33 AM Alexandra Diupina
<adiupina@astralinux.ru> wrote:
>
>
>
>
> 19/03/25 16:20, Fedor Pchelkin пишет:
> > On Wed, 19. Mar 15:31, Alexandra Diupina wrote:
> >> diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
> >> index f3c4b70b77b9..c02aab58aade 100644
> >> --- a/fs/smb/client/smb2misc.c
> >> +++ b/fs/smb/client/smb2misc.c
> >> @@ -816,11 +816,12 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
> >>              WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
> >>              spin_unlock(&cifs_tcp_ses_lock);
> >>
> >> -            if (tcon->ses)
> >> +            if (tcon->ses) {
> >>                      server = tcon->ses->server;
> >> -
> >> -            cifs_server_dbg(FYI, "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
> >> -                            tcon->tid, persistent_fid, volatile_fid);
> >> +                    cifs_server_dbg(FYI,
> >> +                                                    "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
> >> +                                                    tcon->tid, persistent_fid, volatile_fid);
> >> +            }
> > Something is wrong with the indentation. Usually scripts/checkpatch.pl
> > can give some feedback on this, too.
> >
> > CHECK: Alignment should match open parenthesis
> > #32: FILE: fs/smb/client/smb2misc.c:822:
> > +                     cifs_server_dbg(FYI,
> > +                                                     "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
>
> In the *.patch file, everything was fine with indents,
> so the checkpatch.pl script completed without errors.
> But when sending, the indents got corrupted for some
> reason. I'll send the second version
> >
> >>
> >>              return 0;
> >>      }
> >> --
> >> 2.30.2
>
>
diff mbox series

Patch

diff --git a/fs/smb/client/smb2misc.c b/fs/smb/client/smb2misc.c
index f3c4b70b77b9..c02aab58aade 100644
--- a/fs/smb/client/smb2misc.c
+++ b/fs/smb/client/smb2misc.c
@@ -816,11 +816,12 @@  smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
 		WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
 		spin_unlock(&cifs_tcp_ses_lock);
 
-		if (tcon->ses)
+		if (tcon->ses) {
 			server = tcon->ses->server;
-
-		cifs_server_dbg(FYI, "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
-				tcon->tid, persistent_fid, volatile_fid);
+			cifs_server_dbg(FYI,
+							"tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n",
+							tcon->tid, persistent_fid, volatile_fid);
+		}
 
 		return 0;
 	}