net: stmmac: add sanity check to device_property_read_u32_array call
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> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
cf29a49879
commit
760f1dc295
@ -242,6 +242,7 @@ int stmmac_mdio_reset(struct mii_bus *bus)
|
|||||||
if (priv->device->of_node) {
|
if (priv->device->of_node) {
|
||||||
struct gpio_desc *reset_gpio;
|
struct gpio_desc *reset_gpio;
|
||||||
u32 delays[3];
|
u32 delays[3];
|
||||||
|
int ret;
|
||||||
|
|
||||||
reset_gpio = devm_gpiod_get_optional(priv->device,
|
reset_gpio = devm_gpiod_get_optional(priv->device,
|
||||||
"snps,reset",
|
"snps,reset",
|
||||||
@ -249,9 +250,15 @@ int stmmac_mdio_reset(struct mii_bus *bus)
|
|||||||
if (IS_ERR(reset_gpio))
|
if (IS_ERR(reset_gpio))
|
||||||
return PTR_ERR(reset_gpio);
|
return PTR_ERR(reset_gpio);
|
||||||
|
|
||||||
device_property_read_u32_array(priv->device,
|
ret = device_property_read_u32_array(priv->device,
|
||||||
"snps,reset-delays-us",
|
"snps,reset-delays-us",
|
||||||
delays, ARRAY_SIZE(delays));
|
delays,
|
||||||
|
ARRAY_SIZE(delays));
|
||||||
|
if (ret) {
|
||||||
|
dev_err(ndev->dev.parent,
|
||||||
|
"invalid property snps,reset-delays-us\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (delays[0])
|
if (delays[0])
|
||||||
msleep(DIV_ROUND_UP(delays[0], 1000));
|
msleep(DIV_ROUND_UP(delays[0], 1000));
|
||||||
|
Loading…
Reference in New Issue
Block a user