net: eth-uclass: add return value check
Add return value check
Signed-off-by: Peng Fan <peng.fan@nxp.com>
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 struct eth_uclass_priv *eth_get_uclass_priv(void)
{
struct uclass *uc;
+ int ret;
- uclass_get(UCLASS_ETH, &uc);
+ ret = uclass_get(UCLASS_ETH, &uc);
+ if (ret)
+ return NULL;
+
assert(uc);
return uc->priv;
}
@@ -102,6 +106,7 @@
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 @@
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.