Commit 77577bf9 authored by Mike Sinkovsky's avatar Mike Sinkovsky Committed by David S. Miller

net: WIZnet drivers: fix possible NULL dereference

This fixes possible null dereference in probe() function: when both
.mac_addr and .link_gpio are unknown, dev.platform_data may be NULL
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMike Sinkovsky <msink@permonline.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9b17876f
...@@ -682,7 +682,7 @@ static int __devinit w5100_hw_probe(struct platform_device *pdev) ...@@ -682,7 +682,7 @@ static int __devinit w5100_hw_probe(struct platform_device *pdev)
return ret; return ret;
priv->irq = irq; priv->irq = irq;
priv->link_gpio = data->link_gpio; priv->link_gpio = data ? data->link_gpio : -EINVAL;
if (gpio_is_valid(priv->link_gpio)) { if (gpio_is_valid(priv->link_gpio)) {
char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL); char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
if (!link_name) if (!link_name)
......
...@@ -594,7 +594,7 @@ static int __devinit w5300_hw_probe(struct platform_device *pdev) ...@@ -594,7 +594,7 @@ static int __devinit w5300_hw_probe(struct platform_device *pdev)
return ret; return ret;
priv->irq = irq; priv->irq = irq;
priv->link_gpio = data->link_gpio; priv->link_gpio = data ? data->link_gpio : -EINVAL;
if (gpio_is_valid(priv->link_gpio)) { if (gpio_is_valid(priv->link_gpio)) {
char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL); char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL);
if (!link_name) if (!link_name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment