aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Fan <peng.fan@nxp.com>2020-05-03 22:41:13 +0800
committerStefano Babic <sbabic@denx.de>2020-05-10 13:24:41 +0200
commitd2b70205dd67f32427dde4f1a7a8966f4924dfad (patch)
tree19a54a47c9efe3dd2d21ffde0babc404de3c9f12
parenta6979f78bcba76611e5e3fd6226b5b79c8021c2e (diff)
downloadu-boot-d2b70205dd67f32427dde4f1a7a8966f4924dfad.zip
u-boot-d2b70205dd67f32427dde4f1a7a8966f4924dfad.tar.gz
u-boot-d2b70205dd67f32427dde4f1a7a8966f4924dfad.tar.bz2
net: eth-uclass: add return value check
Add return value check Signed-off-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r--net/eth-uclass.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 8bf2eab..950a48d 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -40,8 +40,12 @@ static int eth_errno;
static struct eth_uclass_priv *eth_get_uclass_priv(void)
{
struct uclass *uc;
+ int ret;
+
+ ret = uclass_get(UCLASS_ETH, &uc);
+ if (ret)
+ return NULL;
- uclass_get(UCLASS_ETH, &uc);
assert(uc);
return uc->priv;
}
@@ -102,6 +106,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
struct udevice *it;
struct uclass *uc;
int len = strlen("eth");
+ int ret;
/* Must be longer than 3 to be an alias */
if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
@@ -109,7 +114,10 @@ struct udevice *eth_get_dev_by_name(const char *devname)
seq = simple_strtoul(startp, &endp, 10);
}
- uclass_get(UCLASS_ETH, &uc);
+ ret = uclass_get(UCLASS_ETH, &uc);
+ if (ret)
+ return NULL;
+
uclass_foreach_dev(it, uc) {
/*
* We need the seq to be valid, so try to probe it.