Skip to content

Commit 1037917

Browse files
namjaejeonsmfrench
authored andcommitted
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: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 68477b5 commit 1037917

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/smb/server/oplock.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,9 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci)
146146
{
147147
struct oplock_info *opinfo;
148148

149-
if (list_empty(&ci->m_op_list))
150-
return NULL;
151-
152149
down_read(&ci->m_lock);
153-
opinfo = list_first_entry(&ci->m_op_list, struct oplock_info,
154-
op_entry);
150+
opinfo = list_first_entry_or_null(&ci->m_op_list, struct oplock_info,
151+
op_entry);
155152
if (opinfo) {
156153
if (opinfo->conn == NULL ||
157154
!atomic_inc_not_zero(&opinfo->refcount))

0 commit comments

Comments
 (0)