All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: add return value check of genphy_read_status()
@ 2024-03-14  6:30 Alexandra Diupina
  2024-03-14 13:02 ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandra Diupina @ 2024-03-14  6:30 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Alexandra Diupina, Florian Fainelli, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Sebastian Reichel, netdev, linux-kernel, lvc-project

Need to check return value of genphy_read_status(),
because higher in the call hierarchy is the
dsa_register_switch() function,
which is used in various drivers.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 33615367f378 ("net: dsa: Support internal phy on 'cpu' port")
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
---
 net/dsa/port.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index c42dac87671b..c411f30bb5f6 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1765,7 +1765,9 @@ static int dsa_shared_port_fixed_link_register_of(struct dsa_port *dp)
 		mode = PHY_INTERFACE_MODE_NA;
 	phydev->interface = mode;
 
-	genphy_read_status(phydev);
+	err = genphy_read_status(phydev);
+	if (err)
+		return err;
 
 	if (ds->ops->adjust_link)
 		ds->ops->adjust_link(ds, port, phydev);
-- 
2.30.2


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

* Re: [PATCH] net: dsa: add return value check of genphy_read_status()
  2024-03-14  6:30 [PATCH] net: dsa: add return value check of genphy_read_status() Alexandra Diupina
@ 2024-03-14 13:02 ` Andrew Lunn
  2024-03-15 10:25   ` Александра Дюпина
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-03-14 13:02 UTC (permalink / raw)
  To: Alexandra Diupina
  Cc: Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Sebastian Reichel, netdev,
	linux-kernel, lvc-project

On Thu, Mar 14, 2024 at 09:30:08AM +0300, Alexandra Diupina wrote:
> Need to check return value of genphy_read_status(),
> because higher in the call hierarchy is the
> dsa_register_switch() function,
> which is used in various drivers.

I don't understand the commit message. Why is it important to
dsa_register_switch()?

	Andrew

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

* Re: [PATCH] net: dsa: add return value check of genphy_read_status()
  2024-03-14 13:02 ` Andrew Lunn
@ 2024-03-15 10:25   ` Александра Дюпина
  2024-03-20 23:48     ` Florian Fainelli
  0 siblings, 1 reply; 6+ messages in thread
From: Александра Дюпина @ 2024-03-15 10:25 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Sebastian Reichel, netdev,
	linux-kernel, lvc-project

Hello, Andrew!

The dsa_register_switch() function is used in various DSA
drivers (in probe function), so it is necessary to check all
possible errors. If the return value (may be an error code)
of genphy_read_status() is not checked in
dsa_shared_port_fixed_link_register_of(), a possible error
in dsa_register_switch() may be missed.

14/03/24 16:02, Andrew Lunn пишет:

> On Thu, Mar 14, 2024 at 09:30:08AM +0300, Alexandra Diupina wrote:
>> Need to check return value of genphy_read_status(),
>> because higher in the call hierarchy is the
>> dsa_register_switch() function,
>> which is used in various drivers.
> I don't understand the commit message. Why is it important to
> dsa_register_switch()?
>
> 	Andrew


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

* Re: [PATCH] net: dsa: add return value check of genphy_read_status()
  2024-03-15 10:25   ` Александра Дюпина
@ 2024-03-20 23:48     ` Florian Fainelli
  2024-03-21 12:06       ` Alexandra Diupina
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Fainelli @ 2024-03-20 23:48 UTC (permalink / raw)
  To: Александра
	Дюпина,
	Andrew Lunn
  Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Sebastian Reichel, netdev, linux-kernel,
	lvc-project



On 15/03/2024 03:25, Александра Дюпина wrote:
> Hello, Andrew!

(please do not top-post)

> 
> The dsa_register_switch() function is used in various DSA
> drivers (in probe function), so it is necessary to check all
> possible errors. If the return value (may be an error code)
> of genphy_read_status() is not checked in
> dsa_shared_port_fixed_link_register_of(), a possible error
> in dsa_register_switch() may be missed.

This is not a path that will fail, because the fixed PHY emulation layer 
is not a real piece of hardware, therefore no MDIO read could really 
cause a problem here. I don't have a strong opinion however if you want 
to propagate it properly.
-- 
Florian

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

* Re: [PATCH] net: dsa: add return value check of genphy_read_status()
  2024-03-20 23:48     ` Florian Fainelli
@ 2024-03-21 12:06       ` Alexandra Diupina
  2024-03-27 14:08         ` [lvc-project] " Alexandra Diupina
  0 siblings, 1 reply; 6+ messages in thread
From: Alexandra Diupina @ 2024-03-21 12:06 UTC (permalink / raw)
  To: Florian Fainelli, Andrew Lunn
  Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Sebastian Reichel, netdev, linux-kernel,
	lvc-project



21/03/24 02:48, Florian Fainelli пишет:
>
>
> On 15/03/2024 03:25, Александра Дюпина wrote:
>> Hello, Andrew!
>
> (please do not top-post)
>
>>
>> The dsa_register_switch() function is used in various DSA
>> drivers (in probe function), so it is necessary to check all
>> possible errors. If the return value (may be an error code)
>> of genphy_read_status() is not checked in
>> dsa_shared_port_fixed_link_register_of(), a possible error
>> in dsa_register_switch() may be missed.
>
> This is not a path that will fail, because the fixed PHY emulation 
> layer is not a real piece of hardware, therefore no MDIO read could 
> really cause a problem here. I don't have a strong opinion however if 
> you want to propagate it properly.

Hi, Florian!
I would like to make sure that I have understood you correctly. Checking 
the return value of genphy_read_status() in 
dsa_shared_port_fixed_link_register_of() is not needed because 
dsa_shared_port_fixed_link_register_of() is called if 
of_phy_is_fixed_link()==true (this means that the PHY emulation layer is 
used, link is registered by of_phy_register_fixed_link() without errors 
and therefore there cannot be an error in genphy_read_status()). Right?

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

* Re: [lvc-project] [PATCH] net: dsa: add return value check of genphy_read_status()
  2024-03-21 12:06       ` Alexandra Diupina
@ 2024-03-27 14:08         ` Alexandra Diupina
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandra Diupina @ 2024-03-27 14:08 UTC (permalink / raw)
  To: Florian Fainelli, Andrew Lunn
  Cc: Vladimir Oltean, lvc-project, netdev, Sebastian Reichel,
	linux-kernel, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	David S. Miller

just a friendly reminder

Alexandra


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

end of thread, other threads:[~2024-03-27 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-14  6:30 [PATCH] net: dsa: add return value check of genphy_read_status() Alexandra Diupina
2024-03-14 13:02 ` Andrew Lunn
2024-03-15 10:25   ` Александра Дюпина
2024-03-20 23:48     ` Florian Fainelli
2024-03-21 12:06       ` Alexandra Diupina
2024-03-27 14:08         ` [lvc-project] " Alexandra Diupina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.