Commit 71b91edcaa8388360f7ef702cf064c8fa1c47773

Authored by Peng Fan
Committed by Ye Li
1 parent 2e8bd7bca7

MLK-14862 net: eth-uclass: add return value check

Add return value check

Coverity 392391

Signed-off-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit 3f8052264b97b0bf87452876307ca115b7a518a3)
(cherry picked from commit edd2be5f4b978242bba403f97a9b7e4febbf9bab)
(cherry picked from commit d537b7077a34795941e7cb2bf00161f1cac00a6b)

Showing 1 changed file with 12 additions and 2 deletions Side-by-side Diff

... ... @@ -3,6 +3,8 @@
3 3 * (C) Copyright 2001-2015
4 4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 5 * Joe Hershberger, National Instruments
  6 + * Copyright 2017 NXP
  7 + *
6 8 */
7 9  
8 10 #include <common.h>
9 11  
... ... @@ -40,8 +42,12 @@
40 42 static struct eth_uclass_priv *eth_get_uclass_priv(void)
41 43 {
42 44 struct uclass *uc;
  45 + int ret;
43 46  
44   - uclass_get(UCLASS_ETH, &uc);
  47 + ret = uclass_get(UCLASS_ETH, &uc);
  48 + if (ret)
  49 + return NULL;
  50 +
45 51 assert(uc);
46 52 return uc->priv;
47 53 }
... ... @@ -102,6 +108,7 @@
102 108 struct udevice *it;
103 109 struct uclass *uc;
104 110 int len = strlen("eth");
  111 + int ret;
105 112  
106 113 /* Must be longer than 3 to be an alias */
107 114 if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
... ... @@ -109,7 +116,10 @@
109 116 seq = simple_strtoul(startp, &endp, 10);
110 117 }
111 118  
112   - uclass_get(UCLASS_ETH, &uc);
  119 + ret = uclass_get(UCLASS_ETH, &uc);
  120 + if (ret)
  121 + return NULL;
  122 +
113 123 uclass_foreach_dev(it, uc) {
114 124 /*
115 125 * We need the seq to be valid, so try to probe it.