提交 f40cdfa0 编写于 作者: A Andre Kalb 提交者: zhaoxiaoqiang11

net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices

stable inclusion
from stable-v5.10.168
commit 362a2f5531dc0e5b0b5b3e3a541000dbffa75461
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=362a2f5531dc0e5b0b5b3e3a541000dbffa75461

----------------------------------------------------

[ Upstream commit 422ae7d9 ]

The probe() function is only used for the DP83822 PHY, leaving the
private data pointer uninitialized for the smaller DP83825/26 models.
While all uses of the private data structure are hidden in 82822 specific
callbacks, configuring the interrupt is shared across all models.
This causes a NULL pointer dereference on the smaller PHYs as it accesses
the private data unchecked. Verifying the pointer avoids that.

Fixes: 5dc39fd5 ("net: phy: DP83822: Add ability to advertise Fiber connection")
Signed-off-by: NAndre Kalb <andre.kalb@sma.de>
Reviewed-by: NSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/Y9FzniUhUtbaGKU7@pc6682Signed-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 a5352405
...@@ -247,7 +247,8 @@ static int dp83822_config_intr(struct phy_device *phydev) ...@@ -247,7 +247,8 @@ static int dp83822_config_intr(struct phy_device *phydev)
DP83822_ENERGY_DET_INT_EN | DP83822_ENERGY_DET_INT_EN |
DP83822_LINK_QUAL_INT_EN); DP83822_LINK_QUAL_INT_EN);
if (!dp83822->fx_enabled) /* Private data pointer is NULL on DP83825/26 */
if (!dp83822 || !dp83822->fx_enabled)
misr_status |= DP83822_ANEG_COMPLETE_INT_EN | misr_status |= DP83822_ANEG_COMPLETE_INT_EN |
DP83822_DUP_MODE_CHANGE_INT_EN | DP83822_DUP_MODE_CHANGE_INT_EN |
DP83822_SPEED_CHANGED_INT_EN; DP83822_SPEED_CHANGED_INT_EN;
...@@ -267,7 +268,8 @@ static int dp83822_config_intr(struct phy_device *phydev) ...@@ -267,7 +268,8 @@ static int dp83822_config_intr(struct phy_device *phydev)
DP83822_PAGE_RX_INT_EN | DP83822_PAGE_RX_INT_EN |
DP83822_EEE_ERROR_CHANGE_INT_EN); DP83822_EEE_ERROR_CHANGE_INT_EN);
if (!dp83822->fx_enabled) /* Private data pointer is NULL on DP83825/26 */
if (!dp83822 || !dp83822->fx_enabled)
misr_status |= DP83822_ANEG_ERR_INT_EN | misr_status |= DP83822_ANEG_ERR_INT_EN |
DP83822_WOL_PKT_INT_EN; DP83822_WOL_PKT_INT_EN;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册