diff mbox series

[net] net: phy: qcom: at803x: fix kernel panic with at8031_probe

Message ID 20240325190621.2665-1-ansuelsmth@gmail.com (mailing list archive)
State Accepted
Commit 6a4aee277740d04ac0fd54cfa17cc28261932ddc
Delegated to: Netdev Maintainers
Headers show
Series [net] net: phy: qcom: at803x: fix kernel panic with at8031_probe | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 944 this patch: 944
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 955 this patch: 955
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 955 this patch: 955
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-27--15-00 (tests: 952)

Commit Message

Christian Marangi March 25, 2024, 7:06 p.m. UTC
On reworking and splitting the at803x driver, in splitting function of
at803x PHYs it was added a NULL dereference bug where priv is referenced
before it's actually allocated and then is tried to write to for the
is_1000basex and is_fiber variables in the case of at8031, writing on
the wrong address.

Fix this by correctly setting priv local variable only after
at803x_probe is called and actually allocates priv in the phydev struct.

Reported-by: William Wortel <wwortel@dorpstraat.com>
Cc: <stable@vger.kernel.org>
Fixes: 25d2ba94005f ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/phy/qcom/at803x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Lunn March 25, 2024, 7:40 p.m. UTC | #1
On Mon, Mar 25, 2024 at 08:06:19PM +0100, Christian Marangi wrote:
> On reworking and splitting the at803x driver, in splitting function of
> at803x PHYs it was added a NULL dereference bug where priv is referenced
> before it's actually allocated and then is tried to write to for the
> is_1000basex and is_fiber variables in the case of at8031, writing on
> the wrong address.
> 
> Fix this by correctly setting priv local variable only after
> at803x_probe is called and actually allocates priv in the phydev struct.
> 
> Reported-by: William Wortel <wwortel@dorpstraat.com>
> Cc: <stable@vger.kernel.org>
> Fixes: 25d2ba94005f ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
patchwork-bot+netdevbpf@kernel.org March 28, 2024, 9:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 25 Mar 2024 20:06:19 +0100 you wrote:
> On reworking and splitting the at803x driver, in splitting function of
> at803x PHYs it was added a NULL dereference bug where priv is referenced
> before it's actually allocated and then is tried to write to for the
> is_1000basex and is_fiber variables in the case of at8031, writing on
> the wrong address.
> 
> Fix this by correctly setting priv local variable only after
> at803x_probe is called and actually allocates priv in the phydev struct.
> 
> [...]

Here is the summary with links:
  - [net] net: phy: qcom: at803x: fix kernel panic with at8031_probe
    https://git.kernel.org/netdev/net/c/6a4aee277740

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c
index 4717c59d51d0..e79657f76bea 100644
--- a/drivers/net/phy/qcom/at803x.c
+++ b/drivers/net/phy/qcom/at803x.c
@@ -797,7 +797,7 @@  static int at8031_parse_dt(struct phy_device *phydev)
 
 static int at8031_probe(struct phy_device *phydev)
 {
-	struct at803x_priv *priv = phydev->priv;
+	struct at803x_priv *priv;
 	int mode_cfg;
 	int ccr;
 	int ret;
@@ -806,6 +806,8 @@  static int at8031_probe(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	priv = phydev->priv;
+
 	/* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping
 	 * options.
 	 */