Explorar o código

net: mvpp2x: add check after calloc

After allocating plat the pointer is checked.
Afterwards name is allocated and not checked.

Add the missing check to avoid a possible NULL dereference.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Heinrich Schuchardt %!s(int64=7) %!d(string=hai) anos
pai
achega
b24b1e4b1d
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      drivers/net/mvpp2.c

+ 4 - 0
drivers/net/mvpp2.c

@@ -5598,6 +5598,10 @@ static int mvpp2_base_bind(struct udevice *parent)
 		id += base_id_add;
 
 		name = calloc(1, 16);
+		if (!name) {
+			free(plat);
+			return -ENOMEM;
+		}
 		sprintf(name, "mvpp2-%d", id);
 
 		/* Create child device UCLASS_ETH and bind it */