net: cpsw: Add NULL pointer check
authorFaiz Abbas <faiz_abbas@ti.com>
Mon, 11 Nov 2019 09:52:56 +0000 (15:22 +0530)
committerTom Rini <trini@konsulko.com>
Tue, 3 Dec 2019 13:44:14 +0000 (08:44 -0500)
Add null pointer check to take care of out of memory errors.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
drivers/net/ti/cpsw.c

index 93d53612b53cffa5db1bb1b38b9df3a49fe31127..57625623c262361f77c2231ff8ffa1134a45efa1 100644 (file)
@@ -1224,6 +1224,9 @@ static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
        int ret;
 
        data = calloc(1, sizeof(struct cpsw_platform_data));
+       if (!data)
+               return -ENOMEM;
+
        pdata->priv_pdata = data;
        pdata->iobase = dev_read_addr(dev);
        data->version = CPSW_CTRL_VERSION_2;