From 77577bf93275b485cecb4f358a085949c32e9dcd Mon Sep 17 00:00:00 2001 From: Mike Sinkovsky Date: Tue, 10 Apr 2012 19:53:53 +0000 Subject: [PATCH] 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: Dan Carpenter Signed-off-by: Mike Sinkovsky Signed-off-by: David S. Miller --- drivers/net/ethernet/wiznet/w5100.c | 2 +- drivers/net/ethernet/wiznet/w5300.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c index 18c80982fc6c..a75e9ef5a4ce 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -682,7 +682,7 @@ static int __devinit w5100_hw_probe(struct platform_device *pdev) return ret; priv->irq = irq; - priv->link_gpio = data->link_gpio; + priv->link_gpio = data ? data->link_gpio : -EINVAL; if (gpio_is_valid(priv->link_gpio)) { char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL); if (!link_name) diff --git a/drivers/net/ethernet/wiznet/w5300.c b/drivers/net/ethernet/wiznet/w5300.c index f36addf9d2f6..3306a20ec211 100644 --- a/drivers/net/ethernet/wiznet/w5300.c +++ b/drivers/net/ethernet/wiznet/w5300.c @@ -594,7 +594,7 @@ static int __devinit w5300_hw_probe(struct platform_device *pdev) return ret; priv->irq = irq; - priv->link_gpio = data->link_gpio; + priv->link_gpio = data ? data->link_gpio : -EINVAL; if (gpio_is_valid(priv->link_gpio)) { char *link_name = devm_kzalloc(&pdev->dev, 16, GFP_KERNEL); if (!link_name) -- 2.39.5