public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create()
@ 2022-07-11 17:40 Heinrich Schuchardt
  2022-07-12 10:49 ` Marek Behún
  2022-08-08 19:08 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2022-07-11 17:40 UTC (permalink / raw)
  To: Joe Hershberger, Ramon Fried
  Cc: Marek Behún, T Karthik Reddy, Vladimir Oltean,
	Ariel D'Alessandro, Michal Simek, Nate Drude, u-boot,
	Heinrich Schuchardt

We check if phydev is NULL. Only but if it is non-NULL we set one
component of phydev. But even if it is NULL we set another. We should not
dereference NULL in either case.

Fixes: e24b58f5ed4f ("net: phy: don't require PHY interface mode during PHY creation")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 drivers/net/phy/phy.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 1121b99abf..945642ed93 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -984,10 +984,10 @@ struct phy_device *fixed_phy_create(ofnode node)
 	}
 
 	phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false);
-	if (phydev)
+	if (phydev) {
 		phydev->node = subnode;
-
-	phydev->interface = ofnode_read_phy_mode(node);
+		phydev->interface = ofnode_read_phy_mode(node);
+	}
 
 	return phydev;
 }
-- 
2.36.1


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

* Re: [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create()
  2022-07-11 17:40 [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create() Heinrich Schuchardt
@ 2022-07-12 10:49 ` Marek Behún
  2022-08-08 19:08 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Behún @ 2022-07-12 10:49 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Joe Hershberger, Ramon Fried, T Karthik Reddy, Vladimir Oltean,
	Ariel D'Alessandro, Michal Simek, Nate Drude, u-boot

On Mon, 11 Jul 2022 19:40:13 +0200
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote:

> We check if phydev is NULL. Only but if it is non-NULL we set one
> component of phydev. But even if it is NULL we set another. We should not
> dereference NULL in either case.
> 
> Fixes: e24b58f5ed4f ("net: phy: don't require PHY interface mode during PHY creation")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Marek Behún <kabel@kernel.org>

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

* Re: [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create()
  2022-07-11 17:40 [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create() Heinrich Schuchardt
  2022-07-12 10:49 ` Marek Behún
@ 2022-08-08 19:08 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2022-08-08 19:08 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Joe Hershberger, Ramon Fried, Marek Behún, T Karthik Reddy,
	Vladimir Oltean, Ariel D'Alessandro, Michal Simek, Nate Drude,
	u-boot

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

On Mon, Jul 11, 2022 at 07:40:13PM +0200, Heinrich Schuchardt wrote:

> We check if phydev is NULL. Only but if it is non-NULL we set one
> component of phydev. But even if it is NULL we set another. We should not
> dereference NULL in either case.
> 
> Fixes: e24b58f5ed4f ("net: phy: don't require PHY interface mode during PHY creation")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> Reviewed-by: Marek Behún <kabel@kernel.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2022-08-08 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-11 17:40 [PATCH 1/1] net: phy: possible NULL dereference in fixed_phy_create() Heinrich Schuchardt
2022-07-12 10:49 ` Marek Behún
2022-08-08 19:08 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox