Skip to content

Commit

Permalink
net: freescale: fix potential null pointer dereference
Browse files Browse the repository at this point in the history
Add NULL check before dereferencing pointer _id_ in order to avoid
a potential NULL pointer dereference.

Addresses-Coverity-ID: 1397995
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Gustavo A. R. Silva authored and David S. Miller committed May 31, 2017
1 parent 1b8f869 commit 06d2d64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/ethernet/freescale/fsl_pq_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,21 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
{
const struct of_device_id *id =
of_match_device(fsl_pq_mdio_match, &pdev->dev);
const struct fsl_pq_mdio_data *data = id->data;
const struct fsl_pq_mdio_data *data;
struct device_node *np = pdev->dev.of_node;
struct resource res;
struct device_node *tbi;
struct fsl_pq_mdio_priv *priv;
struct mii_bus *new_bus;
int err;

if (!id) {
dev_err(&pdev->dev, "Failed to match device\n");
return -ENODEV;
}

data = id->data;

dev_dbg(&pdev->dev, "found %s compatible node\n", id->compatible);

new_bus = mdiobus_alloc_size(sizeof(*priv));
Expand Down

0 comments on commit 06d2d64

Please sign in to comment.