linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices
@ 2023-01-25 18:23 Andre Kalb
  2023-01-26  7:21 ` Simon Horman
  2023-01-28  8:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Andre Kalb @ 2023-01-25 18:23 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel
  Cc: Felix Riemann

From: Andre Kalb <andre.kalb@sma.de>

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: 5dc39fd5ef35 ("net: phy: DP83822: Add ability to advertise Fiber connection")
Signed-off-by: Andre Kalb <andre.kalb@sma.de>
---
 drivers/net/phy/dp83822.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index 0b511abb5422..f070aa97c77b 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -232,7 +232,8 @@ static int dp83822_config_intr(struct phy_device *phydev)
 				DP83822_ENERGY_DET_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 |
 				       DP83822_DUP_MODE_CHANGE_INT_EN |
 				       DP83822_SPEED_CHANGED_INT_EN;
@@ -252,7 +253,8 @@ static int dp83822_config_intr(struct phy_device *phydev)
 				DP83822_PAGE_RX_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 |
 				       DP83822_WOL_PKT_INT_EN;
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices
  2023-01-25 18:23 [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices Andre Kalb
@ 2023-01-26  7:21 ` Simon Horman
  2023-01-28  8:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2023-01-26  7:21 UTC (permalink / raw)
  To: Andre Kalb
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Jakub Kicinski, netdev, linux-kernel, Felix Riemann

On Wed, Jan 25, 2023 at 07:23:26PM +0100, Andre Kalb wrote:
> From: Andre Kalb <andre.kalb@sma.de>
> 
> 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: 5dc39fd5ef35 ("net: phy: DP83822: Add ability to advertise Fiber connection")
> Signed-off-by: Andre Kalb <andre.kalb@sma.de>

Reviewed-by: Simon Horman <simon.horman@corigine.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices
  2023-01-25 18:23 [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices Andre Kalb
  2023-01-26  7:21 ` Simon Horman
@ 2023-01-28  8:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-28  8:40 UTC (permalink / raw)
  To: Andre Kalb
  Cc: andrew, hkallweit1, linux, davem, kuba, netdev, linux-kernel,
	felix.riemann

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 25 Jan 2023 19:23:26 +0100 you wrote:
> From: Andre Kalb <andre.kalb@sma.de>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices
    https://git.kernel.org/netdev/net/c/422ae7d9c722

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-28  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 18:23 [PATCH net] net: phy: dp83822: Fix null pointer access on DP83825/DP83826 devices Andre Kalb
2023-01-26  7:21 ` Simon Horman
2023-01-28  8:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).