Skip to contentSkip to conversation

net: cpsw: Add NULL pointer check

PATCH New Faiz Abbas 3 participants 3 messages Nov 11, 2019 – Dec 4, 2019 Network drivers

lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

PATCH 1/1 net: cpsw: Add NULL pointer check

Add null pointer check to take care of out of memory errors.

---
 drivers/net/ti/cpsw.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ti/cpsw.c +3 -0
index 4a990be93e..b710ae4053 100644
@@ -1223,6 +1223,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;
Signature · 1 line
2.19.2
#1 lore raw

PATCH 1/1 net: cpsw: Add NULL pointer check

Quoted 13 lines · Faiz Abbas

Add null pointer check to take care of out of memory errors.

---
  drivers/net/ti/cpsw.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/net/ti/cpsw.c +0 -0
index 4a990be93e..b710ae4053 100644

drivers/net/ti/cpsw.c static int cpsw_eth_ofdata_to_platdata(struct udevice *dev) · line 1231

Quoted 9 lines
drivers/net/ti/cpsw.c +3 -0
@@ -1223,6 +1223,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;
Signature · 2 lines
Best regards,
grygorii
#2 lore raw

PATCH 1/1 net: cpsw: Add NULL pointer check

In reply to Faiz Abbas
Quoted 4 lines · Faiz Abbas

Add null pointer check to take care of out of memory errors.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/fa493017/attachment.sig>