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 88F41156F45; Tue, 9 Jul 2024 11:12:47 +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=1720523567; cv=none; b=OZr48EyqhHK5HnyV2lLCs7jku7+MJaecbYdTRqiX1quy+D5SJIFNY09n6T1onO0XTo0qX9EhwXX+wkwe1pm2k2hYP0zuD8AC4xmtWDOJk/Pdj4RGC2/xsEzOW0lXUn6QPg5w76D6yZKUDOhu5Ao88BzkutK3b2dDTIRrHRD0etk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720523567; c=relaxed/simple; bh=uWkQFVG1R8PA+DPEZc9JFKyBGHNSBBSqYHaiTS2W+PY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pTwufQo32nB1b8Bb1iewltSUU8b12nqY+Jd5oSlcJBnBxdFa/mXJuOIF6stWCDO396y0vJ/fHJ5jRaMId8SrblXVUpr00AODssdi9zgverZf/PoL7nsi0v38Oh+ZPduqoprNMBTgKnsfNezruPLATRAyx080aA7ukS6PW6f4vAk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GFBItXrf; 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="GFBItXrf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9C1CC3277B; Tue, 9 Jul 2024 11:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720523567; bh=uWkQFVG1R8PA+DPEZc9JFKyBGHNSBBSqYHaiTS2W+PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GFBItXrf020PyTZnBga5jU2QzqBq2zibUSI2cLvj2oAFCfAO5sLj/sf6DkEkoWmEz mffQdsz8SedzEUB541/J7zqP0nadeD/9VLfKVUSST8g9xoHdkBsbI5dK8faWBvLVGl 1J2U4JicKnjpcUnTXk73CWwd7l5k1V5uLGvOgem0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrew Lunn , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 035/139] net: dsa: mv88e6xxx: Correct check for empty list Date: Tue, 9 Jul 2024 13:08:55 +0200 Message-ID: <20240709110659.520398560@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240709110658.146853929@linuxfoundation.org> References: <20240709110658.146853929@linuxfoundation.org> User-Agent: quilt/0.67 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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Simon Horman [ Upstream commit 4c7f3950a9fd53a62b156c0fe7c3a2c43b0ba19b ] Since commit a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses") mv88e6xxx_default_mdio_bus() has checked that the return value of list_first_entry() is non-NULL. This appears to be intended to guard against the list chip->mdios being empty. However, it is not the correct check as the implementation of list_first_entry is not designed to return NULL for empty lists. Instead, use list_first_entry_or_null() which does return NULL if the list is empty. Flagged by Smatch. Compile tested only. Reviewed-by: Andrew Lunn Signed-off-by: Simon Horman Link: https://lore.kernel.org/r/20240430-mv88e6xx-list_empty-v3-1-c35c69d88d2e@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/dsa/mv88e6xxx/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 9571e1b1e59ef..354d4af134562 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -131,8 +131,8 @@ struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip) { struct mv88e6xxx_mdio_bus *mdio_bus; - mdio_bus = list_first_entry(&chip->mdios, struct mv88e6xxx_mdio_bus, - list); + mdio_bus = list_first_entry_or_null(&chip->mdios, + struct mv88e6xxx_mdio_bus, list); if (!mdio_bus) return NULL; -- 2.43.0