From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D38817BBF; Mon, 2 Jun 2025 14:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748872823; cv=none; b=KiGREd7uI8qLdKJtx0ZjYTLnMAcaQrIRenh5CZ4KIBRqNkp62+8bqzQ6mgzqqcHLVo+XKgQVkvl7RtJH9f78URKs1Gqv+m3IWNCfCeooLqzi3HXEg/tTdt2XVTNI2pvVuJTbB9KYrdrKvtYIWMrv1F2PSpU2XfWOVW8Z68cLvCI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748872823; c=relaxed/simple; bh=xBbz6+oeaNSV/nGy/L9rXKuII/VsVZN01PADIt1ufQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sQ8K8lkCTxkqlcYup9gAf7yJBAzZWlrXHaxCq9VnQf8hHqpLzwCR/3935dgruFSJarDjrCOtYn/wxbAzTM8864eGmQXayWkHibh21gLMqamP5F5ZrLM0ly8lwStPUkvmI/zrqBZdIZRdDcoLE4yMbwBfRiMVVWoCsqw6DqeXqaU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ONEcSZnD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ONEcSZnD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B3A7C4CEEB; Mon, 2 Jun 2025 14:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748872823; bh=xBbz6+oeaNSV/nGy/L9rXKuII/VsVZN01PADIt1ufQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ONEcSZnDi1voTYd3skXCznWoxhI/pPTsd0NmSRIB73P4Eyr6U3H24Esut0+4+8+P0 5j/Y7A0uY+ousVJShFGyWvQu5x4zrGxlbOI9uuzOJOBo3lEfaAGW0lPcX6Ry/kXVje AARQReiBObv7Ie5w5RYjz8KYE8eOGZ1C+C02ce4A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, kernel test robot , Dan Carpenter , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.14 73/73] ksmbd: use list_first_entry_or_null for opinfo_get_list() Date: Mon, 2 Jun 2025 15:47:59 +0200 Message-ID: <20250602134244.560232728@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134241.673490006@linuxfoundation.org> References: <20250602134241.673490006@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon [ Upstream commit 10379171f346e6f61d30d9949500a8de4336444a ] 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 Reported-by: Dan Carpenter Closes: https://lore.kernel.org/r/202505080231.7OXwq4Te-lkp@intel.com/ Signed-off-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/oplock.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c index 03f606afad93a..d7a8a580d0136 100644 --- a/fs/smb/server/oplock.c +++ b/fs/smb/server/oplock.c @@ -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)) -- 2.39.5