From: Vladimir Oltean <olteanv@gmail.com>
To: Daniil Dulov <d.dulov@aladdin.ru>
Cc: Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Helmut Grohne <helmut.grohne@intenta.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH 18/18] net: dsa: microchip: Check return value of of_get_phy_mode()
Date: Fri, 16 Feb 2024 03:09:28 +0200 [thread overview]
Message-ID: <20240216010928.6gb6abjf5j356f76@skbuf> (raw)
In-Reply-To: <20240211150804.3893-1-d.dulov@aladdin.ru>
Hi Daniil,
On Sun, Feb 11, 2024 at 07:08:04AM -0800, Daniil Dulov wrote:
> of_get_phy_mode() may return an error, so add a check.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: edecfa98f602 ("net: dsa: microchip: look for phy-mode in port nodes")
> Signed-off-by: Daniil Dulov <d.dulov@aladdin.ru>
> ---
> drivers/net/dsa/microchip/ksz_common.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index e3c338624b95..faffce6ea1e1 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -434,8 +434,10 @@ int ksz_switch_register(struct ksz_device *dev,
> continue;
> if (port_num >= dev->mib_port_cnt)
> return -EINVAL;
> - of_get_phy_mode(port,
> + ret = of_get_phy_mode(port,
> &dev->ports[port_num].interface);
> + if (ret)
> + return ret;
> }
> dev->synclko_125 = of_property_read_bool(dev->dev->of_node,
> "microchip,synclko-125");
> --
> 2.25.1
>
Not all functions that may return an error, and that error is ignored,
must be fixed.
Here, if of_get_phy_mode() fails, dev->ports[port_num].interface remains
at its default value (0, or PHY_INTERFACE_MODE_NA). It is a valid value
to the rest of the driver at least in some cases (user ports connected
to internal PHYs). And since device tree is ABI, you are proposing to
break something that may have used to work, by making a previously well
treated path now cause an error.
Sorry, NACK even as a matter of principle, do not even bother to resend this
without a more careful analysis.
prev parent reply other threads:[~2024-02-16 1:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-11 15:08 [PATCH 18/18] net: dsa: microchip: Check return value of of_get_phy_mode() Daniil Dulov
2024-02-13 0:50 ` Jakub Kicinski
2024-02-13 3:19 ` Arun.Ramadoss
2024-02-16 1:09 ` Vladimir Oltean [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216010928.6gb6abjf5j356f76@skbuf \
--to=olteanv@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@lunn.ch \
--cc=d.dulov@aladdin.ru \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=helmut.grohne@intenta.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox