Commit 10379171 authored by Namjae Jeon's avatar Namjae Jeon Committed by Steve French
Browse files

ksmbd: use list_first_entry_or_null for opinfo_get_list()



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: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202505080231.7OXwq4Te-lkp@intel.com/


Signed-off-by: default avatarNamjae Jeon <linkinjeon@kernel.org>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 68477b5d
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -146,11 +146,8 @@ 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,
	opinfo = list_first_entry_or_null(&ci->m_op_list, struct oplock_info,
					  op_entry);
	if (opinfo) {
		if (opinfo->conn == NULL ||