]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ksmbd: use list_first_entry_or_null for opinfo_get_list()
authorNamjae Jeon <linkinjeon@kernel.org>
Tue, 20 May 2025 00:25:03 +0000 (09:25 +0900)
committerSteve French <stfrench@microsoft.com>
Thu, 22 May 2025 03:30:39 +0000 (22:30 -0500)
The list_first_entry() macro never returns NULL.  If the list is
empty then it returns an invalid pointer.  Use list_first_entry_or_null()
to check if the list is empty.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202505080231.7OXwq4Te-lkp@intel.com/
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/oplock.c

index 03f606afad93a09afc802d41cdbd4c47e1fdf5e8..d7a8a580d013622dd9a542dbd497f3c2a31c7f8f 100644 (file)
@@ -146,12 +146,9 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci)
 {
        struct oplock_info *opinfo;
 
-       if (list_empty(&ci->m_op_list))
-               return NULL;
-
        down_read(&ci->m_lock);
-       opinfo = list_first_entry(&ci->m_op_list, struct oplock_info,
-                                       op_entry);
+       opinfo = list_first_entry_or_null(&ci->m_op_list, struct oplock_info,
+                                         op_entry);
        if (opinfo) {
                if (opinfo->conn == NULL ||
                    !atomic_inc_not_zero(&opinfo->refcount))