[PATCH 05/61] smb: Prefer IS_ERR_OR_NULL over manual NULl check

From: Philipp Hahn

Date: Tue Mar 10 2026 - 08:21:05 EST


Prefer using IS_ERR_OR_NULL() over using IS_ERR() and a manual NULL
check.

Change generated with coccinelle.

To: Steve French <sfrench@xxxxxxxxx>
To: Paulo Alcantara <pc@xxxxxxxxxxxxx>
To: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx>
To: Shyam Prasad N <sprasad@xxxxxxxxxxxxx>
To: Tom Talpey <tom@xxxxxxxxxx>
To: Bharath SM <bharathsm@xxxxxxxxxxxxx>
Cc: linux-cifs@xxxxxxxxxxxxxxx
Cc: samba-technical@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Philipp Hahn <phahn-oss@xxxxxx>
---
fs/smb/client/cifsglob.h | 2 +-
fs/smb/client/connect.c | 2 +-
fs/smb/client/readdir.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 6f9b6c72962b09260542b711d4c64e7dc42c7845..fb731b2609465ebe50742936b458aba210ecbd4a 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -1336,7 +1336,7 @@ void cifs_put_tlink(struct tcon_link *tlink);
static inline struct tcon_link *
cifs_get_tlink(struct tcon_link *tlink)
{
- if (tlink && !IS_ERR(tlink))
+ if (!IS_ERR_OR_NULL(tlink))
atomic_inc(&tlink->tl_count);
return tlink;
}
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 3bad2c5c523dbd1d4b1ab253567984612be0f348..aa12d327894b270b59ea30be0e6d77b4188fc98f 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -2895,7 +2895,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
void
cifs_put_tlink(struct tcon_link *tlink)
{
- if (!tlink || IS_ERR(tlink))
+ if (IS_ERR_OR_NULL(tlink))
return;

if (!atomic_dec_and_test(&tlink->tl_count) ||
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c
index be22bbc4a65a03ec64b87d8505d1496279f22efc..3e9260cca196ea8ab17aad82c4824ec5e468e2e7 100644
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -165,7 +165,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,
inode = ERR_PTR(-ENOMEM);
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
- if (alias && !IS_ERR(alias))
+ if (!IS_ERR_OR_NULL(alias))
dput(alias);
}
dput(dentry);

--
2.43.0