From: Colin King <colin.king@canonical.com>
To: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S . Miller" <davem@davemloft.net>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] net: stmmac: add sanity check to device_property_read_u32_array call
Date: Mon, 17 Jun 2019 17:58:36 +0100 [thread overview]
Message-ID: <20190617165836.4673-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Currently the call to device_property_read_u32_array is not error checked
leading to potential garbage values in the delays array that are then used
in msleep delays. Add a sanity check to the property fetching.
Addresses-Coverity: ("Uninitialized scalar variable")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index da310de06bf6..5b7923c0698c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -242,6 +242,7 @@ int stmmac_mdio_reset(struct mii_bus *bus)
if (priv->device->of_node) {
struct gpio_desc *reset_gpio;
u32 delays[3];
+ int ret;
reset_gpio = devm_gpiod_get_optional(priv->device,
"snps,reset",
@@ -249,9 +250,15 @@ int stmmac_mdio_reset(struct mii_bus *bus)
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
- device_property_read_u32_array(priv->device,
- "snps,reset-delays-us",
- delays, ARRAY_SIZE(delays));
+ ret = device_property_read_u32_array(priv->device,
+ "snps,reset-delays-us",
+ delays,
+ ARRAY_SIZE(delays));
+ if (ret) {
+ dev_err(ndev->dev.parent,
+ "invalid property snps,reset-delays-us\n");
+ return -EINVAL;
+ }
if (delays[0])
msleep(DIV_ROUND_UP(delays[0], 1000));
--
2.20.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2019-06-17 16:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 16:58 Colin King [this message]
2019-06-19 1:04 ` [PATCH] net: stmmac: add sanity check to device_property_read_u32_array call David Miller
2019-06-19 5:13 ` Martin Blumenstingl
2019-06-19 6:55 ` Colin Ian King
2019-06-20 1:34 ` Martin Blumenstingl
2019-06-25 4:44 ` Martin Blumenstingl
2019-06-25 7:58 ` Colin Ian King
2019-06-28 4:15 ` Martin Blumenstingl
2019-06-28 8:32 ` Colin Ian King
2019-06-28 16:05 ` Martin Blumenstingl
2019-07-01 22:43 ` Martin Blumenstingl
2019-07-02 6:48 ` Colin Ian King
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=20190617165836.4673-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=joabreu@synopsys.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.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;
as well as URLs for NNTP newsgroup(s).