diff mbox series

[U-Boot,1/1] net: mvpp2x: add check after calloc

Message ID 20180307023904.3823-1-xypron.glpk@gmx.de
State Accepted
Commit b24b1e4b1d6776ca12a57eff77956bce77b2e56f
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/1] net: mvpp2x: add check after calloc | expand

Commit Message

Heinrich Schuchardt March 7, 2018, 2:39 a.m. UTC
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>
---
 drivers/net/mvpp2.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Joe Hershberger March 7, 2018, 6:03 p.m. UTC | #1
On Tue, Mar 6, 2018 at 8:39 PM, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
> 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>
Joe Hershberger March 26, 2018, 7:24 p.m. UTC | #2
Hi Heinrich,

https://patchwork.ozlabs.org/patch/882382/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index e3d31a560d..62c0c2be06 100644
--- a/drivers/net/mvpp2.c
+++ b/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 */