diff mbox series

[U-Boot] net: cpsw: Add NULL pointer check

Message ID 20191111095256.3528-1-faiz_abbas@ti.com
State Accepted
Commit ae3ef109c308652d2143019038a49b43917fdf12
Delegated to: Tom Rini
Headers show
Series [U-Boot] net: cpsw: Add NULL pointer check | expand

Commit Message

Faiz Abbas Nov. 11, 2019, 9:52 a.m. UTC
Add null pointer check to take care of out of memory errors.

Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
---
 drivers/net/ti/cpsw.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Grygorii Strashko Nov. 11, 2019, 4:46 p.m. UTC | #1
On 11/11/2019 11:52, Faiz Abbas wrote:
> Add null pointer check to take care of out of memory errors.
> 
> Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
> ---
>   drivers/net/ti/cpsw.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
> index 4a990be93e..b710ae4053 100644
> --- a/drivers/net/ti/cpsw.c
> +++ b/drivers/net/ti/cpsw.c
> @@ -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;
> 

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Tom Rini Dec. 4, 2019, 4:01 a.m. UTC | #2
On Mon, Nov 11, 2019 at 03:22:56PM +0530, Faiz Abbas wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c
index 4a990be93e..b710ae4053 100644
--- a/drivers/net/ti/cpsw.c
+++ b/drivers/net/ti/cpsw.c
@@ -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;