[PATCH] ppc32: Check return of ppc_sys_get_pdata before accessing pointer
authorKumar Gala <galak@freescale.com>
Sat, 25 Jun 2005 21:54:36 +0000 (14:54 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 25 Jun 2005 23:24:26 +0000 (16:24 -0700)
Ensure that the returned pointer from ppc_sys_get_pdata is not NULL before we
start using it.  This handles any cases where we have variants of processors
on the same board with different functionality.

Signed-off-by: Kumar Gala <kumar.gala@freescale.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc/platforms/83xx/mpc834x_sys.c
arch/ppc/platforms/85xx/mpc8540_ads.c
arch/ppc/platforms/85xx/mpc8560_ads.c
arch/ppc/platforms/85xx/sbc8560.c
arch/ppc/platforms/85xx/stx_gp3.c

index 37ece1542799cefdb069ff58e120fcfe5a89af86..ddd04d4c1ea9ecb0b95413d6e51fc01b0856fe38 100644 (file)
@@ -94,20 +94,24 @@ mpc834x_sys_setup_arch(void)
 
        /* setup the board related information for the enet controllers */
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC1);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC83xx_IRQ_EXT1;
-       pdata->phyid = 0;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC83xx_IRQ_EXT1;
+               pdata->phyid = 0;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       }
 
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC2);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC83xx_IRQ_EXT2;
-       pdata->phyid = 1;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC83xx_IRQ_EXT2;
+               pdata->phyid = 1;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       }
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)
index a2ed611cd936877f836e381b23c14cf0193969a2..ddd2e9a5bb121306863ce560ca48c967f562277a 100644 (file)
@@ -92,28 +92,34 @@ mpc8540ads_setup_arch(void)
 
        /* setup the board related information for the enet controllers */
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 0;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 0;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       }
 
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 1;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
-
-       pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_FEC);
-       pdata->board_flags = 0;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 3;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet2addr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 1;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       }
+
+       if (pdata) {
+               pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_FEC);
+               pdata->board_flags = 0;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 3;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet2addr, 6);
+       }
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)
index d87dfd5ce0a23d62fed242154763b70e99e56f17..e18380258b6889b6e6bc77e875fc32299ebca10e 100644 (file)
@@ -90,20 +90,24 @@ mpc8560ads_setup_arch(void)
 
        /* setup the board related information for the enet controllers */
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 0;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 0;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       }
 
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 1;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 1;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       }
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)
index 3dbdd73618ebd9ce31d7377e60b9a2d57ffa3e33..165df94d4aa6d6d248479220e64b8005333aef1c 100644 (file)
@@ -129,20 +129,24 @@ sbc8560_setup_arch(void)
 
        /* setup the board related information for the enet controllers */
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT6;
-       pdata->phyid = 25;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT6;
+               pdata->phyid = 25;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       }
 
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
-       pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
-       pdata->interruptPHY = MPC85xx_IRQ_EXT7;
-       pdata->phyid = 26;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       if (pdata) {
+               pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR;
+               pdata->interruptPHY = MPC85xx_IRQ_EXT7;
+               pdata->phyid = 26;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       }
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)
index 9455bb6b45e933dfe220c62afe96a8bf4543b1ac..bb41265cfc85ca72675db8fd4ae7b46e9b8dfaad 100644 (file)
@@ -122,19 +122,23 @@ gp3_setup_arch(void)
 
        /* setup the board related information for the enet controllers */
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
-/*     pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 2;
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       if (pdata) {
+       /*      pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 2;
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enetaddr, 6);
+       }
 
        pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC2);
-/*     pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
-       pdata->interruptPHY = MPC85xx_IRQ_EXT5;
-       pdata->phyid = 4;
-       /* fixup phy address */
-       pdata->phy_reg_addr += binfo->bi_immr_base;
-       memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       if (pdata) {
+       /*      pdata->board_flags = FSL_GIANFAR_BRD_HAS_PHY_INTR; */
+               pdata->interruptPHY = MPC85xx_IRQ_EXT5;
+               pdata->phyid = 4;
+               /* fixup phy address */
+               pdata->phy_reg_addr += binfo->bi_immr_base;
+               memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6);
+       }
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)