diff mbox

[10/11] spi/s3c64xx: improve error handling

Message ID 0de501cd76c2$ea07dfd0$be179f70$%kim@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kim Kukjin Aug. 10, 2012, 6:39 a.m. UTC
Arnd Bergmann wrote:
> 
> When a device tree definition os an s3c64xx SPI master is missing
> a "controller-data" subnode, the newly added s3c64xx_get_slave_ctrldata
> function might use uninitialized memory in place of that node,
> which was correctly reported by gcc.
> 
> Without this patch, building s3c6400_defconfig results in:
> 
> drivers/spi/spi-s3c64xx.c: In function
> 's3c64xx_get_slave_ctrldata.isra.25':
> drivers/spi/spi-s3c64xx.c:841:5: warning: 'data_np' may be used
> uninitialized in this function [-Wuninitialized]
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Thomas Abraham <thomas.abraham@linaro.org>
> Cc: Jaswinder Singh <jaswinder.singh@linaro.org>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Kukjin Kim <kgene.kim@samsung.com>
> ---
>  drivers/spi/spi-s3c64xx.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index 646a765..cfa2c35 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -826,7 +826,7 @@ static struct s3c64xx_spi_csinfo
> *s3c64xx_get_slave_ctrldata(
>  				struct spi_device *spi)
>  {
>  	struct s3c64xx_spi_csinfo *cs;
> -	struct device_node *slave_np, *data_np;
> +	struct device_node *slave_np, *data_np = NULL;
>  	u32 fb_delay = 0;
> 
>  	slave_np = spi->dev.of_node;
> --
> 1.7.10

Looks ok to me,
Acked-by: Kukjin Kim <kgene.kim@samsung.com>

BTW for same reason, probably, we need following fix?

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.

----
From: Kukjin Kim <kgene.kim@samsung.com>

Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
---
 arch/arm/mach-tegra/tegra2_emc.c             |    4 ++--
 arch/c6x/kernel/setup.c                      |    2 +-
 arch/powerpc/kernel/ibmebus.c                |    2 +-
 arch/powerpc/kernel/pci_of_scan.c            |    2 +-
 arch/powerpc/kernel/prom.c                   |    2 +-
 arch/powerpc/kernel/rtas_pci.c               |    2 +-
 arch/powerpc/kernel/vio.c                    |    2 +-
 arch/powerpc/platforms/44x/warp.c            |    2 +-
 arch/powerpc/platforms/cell/setup.c          |    2 +-
 arch/powerpc/platforms/powernv/opal.c        |    2 +-
 arch/powerpc/platforms/powernv/pci-ioda.c    |    2 +-
 arch/powerpc/platforms/powernv/pci-p5ioc2.c  |    2 +-
 arch/powerpc/platforms/pseries/eeh.c         |   12 ++++++------
 arch/powerpc/sysdev/mv64x60_dev.c            |    2 +-
 drivers/dma/fsldma.c                         |    2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c  |    2 +-
 drivers/hwmon/ads1015.c                      |    2 +-
 drivers/i2c/busses/i2c-powermac.c            |    2 +-
 drivers/i2c/busses/i2c-pxa-pci.c             |    2 +-
 drivers/i2c/i2c-mux.c                        |    2 +-
 drivers/iio/adc/at91_adc.c                   |    2 +-
 drivers/input/keyboard/samsung-keypad.c      |    2 +-
 drivers/leds/leds-gpio.c                     |    2 +-
 drivers/net/ethernet/freescale/fsl_pq_mdio.c |    2 +-
 drivers/net/phy/mdio-mux.c                   |    2 +-
 drivers/of/of_i2c.c                          |    2 +-
 drivers/of/of_mdio.c                         |    2 +-
 drivers/of/of_pci.c                          |    2 +-
 drivers/of/platform.c                        |    6 +++---
 drivers/pinctrl/pinctrl-imx.c                |    4 ++--
 drivers/pinctrl/pinctrl-tegra.c              |    2 +-
 drivers/pinctrl/spear/pinctrl-spear.c        |    2 +-
 drivers/regulator/da9052-regulator.c         |    2 +-
 drivers/regulator/mc13xxx-regulator-core.c   |    2 +-
 drivers/regulator/of_regulator.c             |    2 +-
 drivers/spi/spi.c                            |    2 +-
 drivers/tty/hvc/hvc_opal.c                   |    2 +-
 37 files changed, 46 insertions(+), 46 deletions(-)

Comments

Arnd Bergmann Aug. 10, 2012, 7:34 a.m. UTC | #1
On Friday 10 August 2012, Kukjin Kim wrote:

> BTW for same reason, probably, we need following fix?
> 
>  arch/arm/mach-tegra/tegra2_emc.c             |    4 ++--
>  arch/c6x/kernel/setup.c                      |    2 +-
>  arch/powerpc/kernel/ibmebus.c                |    2 +-
>  arch/powerpc/kernel/pci_of_scan.c            |    2 +-
>  arch/powerpc/kernel/prom.c                   |    2 +-
>  arch/powerpc/kernel/rtas_pci.c               |    2 +-
>  arch/powerpc/kernel/vio.c                    |    2 +-
>  arch/powerpc/platforms/44x/warp.c            |    2 +-
> ...

Actually not. The difference is that only s3c64xx_get_slave_ctrldata
accesses the node pointer outside of the look (after break).
This fails when there are no child nodes at all. In the other
cases, the only use of the node pointer is inside the loop,
where it is guaranteed to be valid.

	Arnd
diff mbox

Patch

diff --git a/arch/arm/mach-tegra/tegra2_emc.c
b/arch/arm/mach-tegra/tegra2_emc.c
index 5070d83..d045a9e 100644
--- a/arch/arm/mach-tegra/tegra2_emc.c
+++ b/arch/arm/mach-tegra/tegra2_emc.c
@@ -181,7 +181,7 @@  int tegra_emc_set_rate(unsigned long rate)
 #ifdef CONFIG_OF
 static struct device_node *tegra_emc_ramcode_devnode(struct device_node
*np)
 {
-	struct device_node *iter;
+	struct device_node *iter = NULL;
 	u32 reg;
 
 	for_each_child_of_node(np, iter) {
@@ -198,7 +198,7 @@  static struct tegra_emc_pdata *tegra_emc_dt_parse_pdata(
 		struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *tnp, *iter;
+	struct device_node *tnp, *iter = NULL;
 	struct tegra_emc_pdata *pdata;
 	int ret, i, num_tables;
 
diff --git a/arch/c6x/kernel/setup.c b/arch/c6x/kernel/setup.c
index f4e72bd..0f4cd29 100644
--- a/arch/c6x/kernel/setup.c
+++ b/arch/c6x/kernel/setup.c
@@ -99,7 +99,7 @@  static void __init get_cpuinfo(void)
 	unsigned long core_khz;
 	u64 tmp;
 	struct cpuinfo_c6x *p;
-	struct device_node *node, *np;
+	struct device_node *node, *np = NULL;
 
 	p = &per_cpu(cpu_data, smp_processor_id());
 
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index b01d14e..1147931 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -180,7 +180,7 @@  static int ibmebus_create_device(struct device_node *dn)
 
 static int ibmebus_create_devices(const struct of_device_id *matches)
 {
-	struct device_node *root, *child;
+	struct device_node *root, *child = NULL;
 	int ret = 0;
 
 	root = of_find_node_by_path("/");
diff --git a/arch/powerpc/kernel/pci_of_scan.c
b/arch/powerpc/kernel/pci_of_scan.c
index 30378a1..8344f9a 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -302,7 +302,7 @@  EXPORT_SYMBOL(of_scan_pci_bridge);
 static void __devinit __of_scan_bus(struct device_node *node,
 				    struct pci_bus *bus, int
rescan_existing)
 {
-	struct device_node *child;
+	struct device_node *child = NULL;
 	const u32 *reg;
 	int reglen, devfn;
 	struct pci_dev *dev;
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index f191bf0..b4a021e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -735,7 +735,7 @@  void __init early_init_devtree(void *params)
  */
 struct device_node *of_find_next_cache_node(struct device_node *np)
 {
-	struct device_node *child;
+	struct device_node *child = NULL;
 	const phandle *handle;
 
 	handle = of_get_property(np, "l2-cache", NULL);
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 179af90..b75d76b 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -255,7 +255,7 @@  int __devinit rtas_setup_phb(struct pci_controller *phb)
 
 void __init find_and_init_phbs(void)
 {
-	struct device_node *node;
+	struct device_node *node = NULL;
 	struct pci_controller *phb;
 	struct device_node *root = of_find_node_by_path("/");
 
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 02b3221..37b2a76 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -116,7 +116,7 @@  static int vio_cmo_num_OF_devs(void)
 	 */
 	node_vroot = of_find_node_by_name(NULL, "vdevice");
 	if (node_vroot) {
-		struct device_node *of_node;
+		struct device_node *of_node = NULL;
 		struct property *prop;
 
 		for_each_child_of_node(node_vroot, of_node) {
diff --git a/arch/powerpc/platforms/44x/warp.c
b/arch/powerpc/platforms/44x/warp.c
index 4cfa499..b505ca7 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -172,7 +172,7 @@  static irqreturn_t temp_isr(int irq, void *context)
 
 static int pika_setup_leds(void)
 {
-	struct device_node *np, *child;
+	struct device_node *np, *child = NULL;
 
 	np = of_find_compatible_node(NULL, NULL, "gpio-leds");
 	if (!np) {
diff --git a/arch/powerpc/platforms/cell/setup.c
b/arch/powerpc/platforms/cell/setup.c
index 4ab0876..356fb9c 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -155,7 +155,7 @@  static const struct of_device_id cell_bus_ids[]
__initconst = {
 static int __init cell_publish_devices(void)
 {
 	struct device_node *root = of_find_node_by_path("/");
-	struct device_node *np;
+	struct device_node *np = NULL;
 	int node;
 
 	/* Publish OF platform devices for southbridge IOs */
diff --git a/arch/powerpc/platforms/powernv/opal.c
b/arch/powerpc/platforms/powernv/opal.c
index aaa0dba..4df5f2d 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -279,7 +279,7 @@  static irqreturn_t opal_interrupt(int irq, void *data)
 
 static int __init opal_init(void)
 {
-	struct device_node *np, *consoles;
+	struct device_node *np = NULL, *consoles;
 	const u32 *irqs;
 	int rc, i, irqlen;
 
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c
b/arch/powerpc/platforms/powernv/pci-ioda.c
index 9cda6a1..e08c238 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1317,7 +1317,7 @@  void __init pnv_pci_init_ioda1_phb(struct device_node
*np)
 
 void __init pnv_pci_init_ioda_hub(struct device_node *np)
 {
-	struct device_node *phbn;
+	struct device_node *phbn = NULL;
 	const u64 *prop64;
 	u64 hub_id;
 
diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c
b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
index 2649677..d2565d0 100644
--- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c
+++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
@@ -175,7 +175,7 @@  static void __init pnv_pci_init_p5ioc2_phb(struct
device_node *np,
 
 void __init pnv_pci_init_p5ioc2_hub(struct device_node *np)
 {
-	struct device_node *phbn;
+	struct device_node *phbn = NULL;
 	const u64 *prop64;
 	u64 hub_id;
 	void *tce_mem;
diff --git a/arch/powerpc/platforms/pseries/eeh.c
b/arch/powerpc/platforms/pseries/eeh.c
index ecd394c..4b5913e 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -206,7 +206,7 @@  static size_t eeh_gather_pci_data(struct eeh_dev *edev,
char * buf, size_t len)
 
 	/* Gather status on devices under the bridge */
 	if (dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) {
-		struct device_node *child;
+		struct device_node *child = NULL;
 
 		for_each_child_of_node(dn, child) {
 			if (of_node_to_eeh_dev(child))
@@ -289,7 +289,7 @@  struct device_node *eeh_find_device_pe(struct
device_node *dn)
  */
 static void __eeh_mark_slot(struct device_node *parent, int mode_flag)
 {
-	struct device_node *dn;
+	struct device_node *dn = NULL;
 
 	for_each_child_of_node(parent, dn) {
 		if (of_node_to_eeh_dev(dn)) {
@@ -342,7 +342,7 @@  void eeh_mark_slot(struct device_node *dn, int
mode_flag)
  */
 static void __eeh_clear_slot(struct device_node *parent, int mode_flag)
 {
-	struct device_node *dn;
+	struct device_node *dn = NULL;
 
 	for_each_child_of_node(parent, dn) {
 		if (of_node_to_eeh_dev(dn)) {
@@ -601,7 +601,7 @@  int pcibios_set_pcie_reset_state(struct pci_dev *dev,
enum pcie_reset_state stat
  */
 void __eeh_set_pe_freset(struct device_node *parent, unsigned int *freset)
 {
-	struct device_node *dn;
+	struct device_node *dn = NULL;
 
 	for_each_child_of_node(parent, dn) {
 		if (of_node_to_eeh_dev(dn)) {
@@ -788,7 +788,7 @@  static inline void eeh_restore_one_device_bars(struct
eeh_dev *edev)
  */
 void eeh_restore_bars(struct eeh_dev *edev)
 {
-	struct device_node *dn;
+	struct device_node *dn = NULL;
 	if (!edev)
 		return;
 	
@@ -1050,7 +1050,7 @@  static void eeh_add_device_early(struct device_node
*dn)
  */
 void eeh_add_device_tree_early(struct device_node *dn)
 {
-	struct device_node *sib;
+	struct device_node *sib = NULL;
 
 	for_each_child_of_node(dn, sib)
 		eeh_add_device_tree_early(sib);
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c
b/arch/powerpc/sysdev/mv64x60_dev.c
index 0f6af41..7d4ffd2 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -430,7 +430,7 @@  error:
 
 static int __init mv64x60_device_setup(void)
 {
-	struct device_node *np, *np2;
+	struct device_node *np, *np2 = NULL;
 	struct platform_device *pdev;
 	int id, id2;
 	int err;
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 8f84761..3786bfc 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -1327,7 +1327,7 @@  static void fsl_dma_chan_remove(struct fsldma_chan
*chan)
 static int __devinit fsldma_of_probe(struct platform_device *op)
 {
 	struct fsldma_device *fdev;
-	struct device_node *child;
+	struct device_node *child = NULL;
 	int err;
 
 	fdev = kzalloc(sizeof(*fdev), GFP_KERNEL);
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c
b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 7b11edb..33edf87 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -145,7 +145,7 @@  nouveau_connector_of_detect(struct drm_connector
*connector)
 	struct drm_device *dev = connector->dev;
 	struct nouveau_connector *nv_connector =
nouveau_connector(connector);
 	struct nouveau_encoder *nv_encoder;
-	struct device_node *cn, *dn = pci_device_to_OF_node(dev->pdev);
+	struct device_node *cn = NULL, *dn =
pci_device_to_OF_node(dev->pdev);
 
 	if (!dn ||
 	    !((nv_encoder = find_encoder(connector, OUTPUT_TMDS)) ||
diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index 1958f03..d1ced0d 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -164,7 +164,7 @@  static int ads1015_remove(struct i2c_client *client)
 static int ads1015_get_channels_config_of(struct i2c_client *client)
 {
 	struct ads1015_data *data = i2c_get_clientdata(client);
-	struct device_node *node;
+	struct device_node *node = NULL;
 
 	if (!client->dev.of_node
 	    || !of_get_next_child(client->dev.of_node, NULL))
diff --git a/drivers/i2c/busses/i2c-powermac.c
b/drivers/i2c/busses/i2c-powermac.c
index 5285f85..60b041b 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -340,7 +340,7 @@  static void __devinit
i2c_powermac_register_devices(struct i2c_adapter *adap,
 						    struct pmac_i2c_bus
*bus)
 {
 	struct i2c_client *newdev;
-	struct device_node *node;
+	struct device_node *node = NULL;
 	bool found_onyx = 0;
 
 	/*
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c
b/drivers/i2c/busses/i2c-pxa-pci.c
index 4dc9bef..ca407d5 100644
--- a/drivers/i2c/busses/i2c-pxa-pci.c
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -22,7 +22,7 @@  static struct platform_device *add_i2c_device(struct
pci_dev *dev, int bar)
 	struct platform_device *pdev;
 	struct i2c_pxa_platform_data pdata;
 	struct resource res[2];
-	struct device_node *child;
+	struct device_node *child = NULL;
 	static int devnum;
 	int ret;
 
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 1038c38..cb632a9 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -132,7 +132,7 @@  struct i2c_adapter *i2c_add_mux_adapter(struct
i2c_adapter *parent,
 	 * nothing if !CONFIG_OF.
 	 */
 	if (mux_dev->of_node) {
-		struct device_node *child;
+		struct device_node *child = NULL;
 		u32 reg;
 
 		for_each_child_of_node(mux_dev->of_node, child) {
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index f61780a..52203d4 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -381,7 +381,7 @@  static int at91_adc_probe_dt(struct at91_adc_state *st,
 {
 	struct iio_dev *idev = iio_priv_to_dev(st);
 	struct device_node *node = pdev->dev.of_node;
-	struct device_node *trig_node;
+	struct device_node *trig_node = NULL;
 	int i = 0, ret;
 	u32 prop;
 
diff --git a/drivers/input/keyboard/samsung-keypad.c
b/drivers/input/keyboard/samsung-keypad.c
index a061ba6..6b3334f 100644
--- a/drivers/input/keyboard/samsung-keypad.c
+++ b/drivers/input/keyboard/samsung-keypad.c
@@ -255,7 +255,7 @@  static struct samsung_keypad_platdata
*samsung_keypad_parse_dt(
 	struct samsung_keypad_platdata *pdata;
 	struct matrix_keymap_data *keymap_data;
 	uint32_t *keymap, num_rows = 0, num_cols = 0;
-	struct device_node *np = dev->of_node, *key_np;
+	struct device_node *np = dev->of_node, *key_np = NULL;
 	unsigned int key_count = 0;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index c032b21..7458663 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -168,7 +168,7 @@  static inline int sizeof_gpio_leds_priv(int num_leds)
 #ifdef CONFIG_OF_GPIO
 static struct gpio_leds_priv * __devinit gpio_leds_create_of(struct
platform_device *pdev)
 {
-	struct device_node *np = pdev->dev.of_node, *child;
+	struct device_node *np = pdev->dev.of_node, *child = NULL;
 	struct gpio_leds_priv *priv;
 	int count = 0, ret;
 
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 9527b28..ea34f84 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -260,7 +260,7 @@  static int get_ucc_id_for_range(u64 start, u64 end, u32
*ucc_id)
 static int fsl_pq_mdio_probe(struct platform_device *ofdev)
 {
 	struct device_node *np = ofdev->dev.of_node;
-	struct device_node *tbi;
+	struct device_node *tbi = NULL;
 	struct fsl_pq_mdio_priv *priv;
 	struct fsl_pq_mdio __iomem *regs = NULL;
 	void __iomem *map;
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 5c12018..cb4ceb6 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -99,7 +99,7 @@  int mdio_mux_init(struct device *dev,
 		  void *data)
 {
 	struct device_node *parent_bus_node;
-	struct device_node *child_bus_node;
+	struct device_node *child_bus_node = NULL;
 	int r, ret_val;
 	struct mii_bus *parent_bus;
 	struct mdio_mux_parent_bus *pb;
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
index 1e173f3..6a080c7 100644
--- a/drivers/of/of_i2c.c
+++ b/drivers/of/of_i2c.c
@@ -21,7 +21,7 @@ 
 void of_i2c_register_devices(struct i2c_adapter *adap)
 {
 	void *result;
-	struct device_node *node;
+	struct device_node *node = NULL;
 
 	/* Only register child devices if the adapter has a node pointer set
*/
 	if (!adap->dev.of_node)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 8e6c25f..a52b354 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -33,7 +33,7 @@  MODULE_LICENSE("GPL");
 int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
 {
 	struct phy_device *phy;
-	struct device_node *child;
+	struct device_node *child = NULL;
 	int rc, i;
 
 	/* Mask out all PHYs from auto probing.  Instead the PHYs listed in
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 13e37e2..dfede93 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -18,7 +18,7 @@  static inline int __of_pci_pci_compare(struct device_node
*node,
 struct device_node *of_pci_find_child_device(struct device_node *parent,
 					     unsigned int devfn)
 {
-	struct device_node *node, *node2;
+	struct device_node *node = NULL, *node2 = NULL;
 
 	for_each_child_of_node(parent, node) {
 		if (__of_pci_pci_compare(node, devfn))
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index e44f8c2..58e8374 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -344,7 +344,7 @@  static int of_platform_bus_create(struct device_node
*bus,
 				  struct device *parent, bool strict)
 {
 	const struct of_dev_auxdata *auxdata;
-	struct device_node *child;
+	struct device_node *child = NULL;
 	struct platform_device *dev;
 	const char *bus_id = NULL;
 	void *platform_data = NULL;
@@ -396,7 +396,7 @@  int of_platform_bus_probe(struct device_node *root,
 			  const struct of_device_id *matches,
 			  struct device *parent)
 {
-	struct device_node *child;
+	struct device_node *child = NULL;
 	int rc = 0;
 
 	root = root ? of_node_get(root) : of_find_node_by_path("/");
@@ -445,7 +445,7 @@  int of_platform_populate(struct device_node *root,
 			const struct of_dev_auxdata *lookup,
 			struct device *parent)
 {
-	struct device_node *child;
+	struct device_node *child = NULL;
 	int rc = 0;
 
 	root = root ? of_node_get(root) : of_find_node_by_path("/");
diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c
index 44e9726..0f1d0ba 100644
--- a/drivers/pinctrl/pinctrl-imx.c
+++ b/drivers/pinctrl/pinctrl-imx.c
@@ -485,7 +485,7 @@  static int __devinit imx_pinctrl_parse_groups(struct
device_node *np,
 static int __devinit imx_pinctrl_parse_functions(struct device_node *np,
 			struct imx_pinctrl_soc_info *info, u32 index)
 {
-	struct device_node *child;
+	struct device_node *child = NULL;
 	struct imx_pmx_func *func;
 	struct imx_pin_group *grp;
 	int ret;
@@ -521,7 +521,7 @@  static int __devinit imx_pinctrl_probe_dt(struct
platform_device *pdev,
 				struct imx_pinctrl_soc_info *info)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
+	struct device_node *child = NULL;
 	int ret;
 	u32 nfuncs = 0;
 	u32 i = 0;
diff --git a/drivers/pinctrl/pinctrl-tegra.c
b/drivers/pinctrl/pinctrl-tegra.c
index ae52e4e..253d338 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -295,7 +295,7 @@  int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev
*pctldev,
 				 struct pinctrl_map **map, unsigned
*num_maps)
 {
 	unsigned reserved_maps;
-	struct device_node *np;
+	struct device_node *np = NULL;
 	int ret;
 
 	reserved_maps = 0;
diff --git a/drivers/pinctrl/spear/pinctrl-spear.c
b/drivers/pinctrl/spear/pinctrl-spear.c
index 5d4f44f..ca7a6df 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -126,7 +126,7 @@  int spear_pinctrl_dt_node_to_map(struct pinctrl_dev
*pctldev,
 				 struct pinctrl_map **map, unsigned
*num_maps)
 {
 	struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev);
-	struct device_node *np;
+	struct device_node *np = NULL;
 	struct property *prop;
 	const char *function, *group;
 	int ret, index = 0, count = 0;
diff --git a/drivers/regulator/da9052-regulator.c
b/drivers/regulator/da9052-regulator.c
index 903299c..ce3aa94 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -396,7 +396,7 @@  static int __devinit da9052_regulator_probe(struct
platform_device *pdev)
 	} else {
 #ifdef CONFIG_OF
 		struct device_node *nproot = da9052->dev->of_node;
-		struct device_node *np;
+		struct device_node *np = NULL;
 
 		if (!nproot)
 			return -ENODEV;
diff --git a/drivers/regulator/mc13xxx-regulator-core.c
b/drivers/regulator/mc13xxx-regulator-core.c
index d6eda28..d179f54 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -173,7 +173,7 @@  EXPORT_SYMBOL_GPL(mc13xxx_fixed_regulator_ops);
 #ifdef CONFIG_OF
 int __devinit mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
 {
-	struct device_node *parent, *child;
+	struct device_node *parent, *child = NULL;
 	int num = 0;
 
 	of_node_get(pdev->dev.parent->of_node);
diff --git a/drivers/regulator/of_regulator.c
b/drivers/regulator/of_regulator.c
index 3e4106f..62f59814 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -113,7 +113,7 @@  int of_regulator_match(struct device *dev, struct
device_node *node,
 	unsigned int count = 0;
 	unsigned int i;
 	const char *regulator_comp;
-	struct device_node *child;
+	struct device_node *child = NULL;
 
 	if (!dev || !node)
 		return -EINVAL;
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861..81f20cf 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -811,7 +811,7 @@  err_init_queue:
 static void of_register_spi_devices(struct spi_master *master)
 {
 	struct spi_device *spi;
-	struct device_node *nc;
+	struct device_node *nc = NULL;
 	const __be32 *prop;
 	int rc;
 	int len;
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index 0d2ea0c..07f308e 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -344,7 +344,7 @@  void __init hvc_opal_init_early(void)
 			return;
 		}
 	} else {
-		struct device_node *opal, *np;
+		struct device_node *opal, *np = NULL;
 
 		/* Current OPAL takeover doesn't provide the stdout
 		 * path, so we hard wire it