From: Grant Likely Date: Sat, 22 Mar 2008 03:20:29 +0000 (+1100) Subject: [POWERPC] mpc5200-fec: Fix possible NULL dereference in mdio driver X-Git-Tag: v2.6.25-rc7~23^2~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8c19eb16a7e6df57d0f6d67e42ce026e5d5930b;p=linux-2.6 [POWERPC] mpc5200-fec: Fix possible NULL dereference in mdio driver If the reg property is missing from the phy node (unlikely, but possible), then the kernel will oops with a NULL pointer dereference. This fixes it by checking the pointer first. Signed-off-by: Grant Likely Signed-off-by: Paul Mackerras --- diff --git a/drivers/net/fec_mpc52xx_phy.c b/drivers/net/fec_mpc52xx_phy.c index 1837584c45..6a3ac4ea97 100644 --- a/drivers/net/fec_mpc52xx_phy.c +++ b/drivers/net/fec_mpc52xx_phy.c @@ -109,7 +109,8 @@ static int mpc52xx_fec_mdio_probe(struct of_device *of, const struct of_device_i int irq = irq_of_parse_and_map(child, 0); if (irq != NO_IRQ) { const u32 *id = of_get_property(child, "reg", NULL); - bus->irq[*id] = irq; + if (id) + bus->irq[*id] = irq; } }