From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com,
davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] net: phy: phylink: check the return value of phylink_validate()
Date: Fri, 25 Feb 2022 01:12:46 -0800 [thread overview]
Message-ID: <20220225091246.22085-1-baijiaju1990@gmail.com> (raw)
The function phylink_validate() can fail, so its return value should be
checked.
Fixes: 9525ae83959b ("phylink: add phylink infrastructure")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/net/phy/phylink.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 420201858564..597f7579b29f 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -584,7 +584,9 @@ static int phylink_parse_fixedlink(struct phylink *pl,
bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(pl->link_config.advertising, pl->supported);
- phylink_validate(pl, pl->supported, &pl->link_config);
+ ret = phylink_validate(pl, pl->supported, &pl->link_config);
+ if (ret)
+ return ret;
s = phy_lookup_setting(pl->link_config.speed, pl->link_config.duplex,
pl->supported, true);
@@ -1261,7 +1263,11 @@ struct phylink *phylink_create(struct phylink_config *config,
bitmap_fill(pl->supported, __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(pl->link_config.advertising, pl->supported);
- phylink_validate(pl, pl->supported, &pl->link_config);
+ ret = phylink_validate(pl, pl->supported, &pl->link_config);
+ if (ret < 0) {
+ kfree(pl);
+ return ERR_PTR(ret);
+ }
ret = phylink_parse_mode(pl, fwnode);
if (ret < 0) {
--
2.17.1
next reply other threads:[~2022-02-25 9:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-25 9:12 Jia-Ju Bai [this message]
2022-02-25 9:19 ` Russell King (Oracle)
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=20220225091246.22085-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
/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
all inboxes | Powered by JetHome®