Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1602485

[PATCH 4.9 14/44] bcm63xx_enet: avoid uninitialized variable warning

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.9 14/44] bcm63xx_enet: avoid uninitialized variable warning
Date 2017-03-16 16:10 +0100
Message-ID <tlFco-97-71@gated-at.bofh.it> (permalink)
References <tlEJj-84L-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

commit df384d435a5c034c735df3d9ea87a03172c59b56 upstream.

gcc-7 and probably earlier versions get confused by this function
and print a harmless warning:

drivers/net/ethernet/broadcom/bcm63xx_enet.c: In function 'bcm_enet_open':
drivers/net/ethernet/broadcom/bcm63xx_enet.c:1130:3: error: 'phydev' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds an initialization for the 'phydev' variable when it is unused
and changes the check to test for that NULL pointer to make it clear
that we always pass a valid pointer here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/ethernet/broadcom/bcm63xx_enet.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -913,6 +913,8 @@ static int bcm_enet_open(struct net_devi
 		priv->old_link = 0;
 		priv->old_duplex = -1;
 		priv->old_pause = -1;
+	} else {
+		phydev = NULL;
 	}
 
 	/* mask all interrupts and request them */
@@ -1083,7 +1085,7 @@ static int bcm_enet_open(struct net_devi
 	enet_dmac_writel(priv, priv->dma_chan_int_mask,
 			 ENETDMAC_IRMASK, priv->tx_chan);
 
-	if (priv->has_phy)
+	if (phydev)
 		phy_start(phydev);
 	else
 		bcm_enet_adjust_link(dev);
@@ -1126,7 +1128,7 @@ out_freeirq:
 	free_irq(dev->irq, dev);
 
 out_phy_disconnect:
-	if (priv->has_phy)
+	if (phydev)
 		phy_disconnect(phydev);
 
 	return ret;

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.9 00/44] 4.9.16-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 42/44] [media] rc: raw decoder for keymap protocol is not loaded on register Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 31/44] usb: host: xhci-plat: Fix timeout on removal of hot pluggable xhci controllers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 25/44] usb: dwc3: gadget: make Set Endpoint Configuration macros safe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 27/44] usb: ohci-at91: Do not drop unhandled USB suspend control requests Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 23/44] PCI: Prevent VPD access for QLogic ISP2722 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:00 +0100
  [PATCH 4.9 18/44] efi/arm: Fix boot crash with CONFIG_CPUMASK_OFFSTACK=y Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 17/44] ucount: Remove the atomicity from ucount->count Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 16/44] tracing: Add #undef to fix compile error Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 15/44] cpmac: remove hopeless #warning Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 22/44] powerpc/xics: Work around limitations of OPAL XICS priority handling Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 10/44] mtd: pmcmsp: use kstrndup instead of kmalloc+strncpy Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 24/44] usb: gadget: dummy_hcd: clear usb_gadget region before registration Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 12/44] MIPS: ralink: Remove unused timer functions Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 14/44] bcm63xx_enet: avoid uninitialized variable warning Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 11/44] MIPS: ralink: Cosmetic change to prom_init(). Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  [PATCH 4.9 02/44] USB: serial: digi_acceleport: fix OOB-event processing Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-03-16 16:10 +0100
  Re: [PATCH 4.9 00/44] 4.9.16-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-03-16 20:40 +0100
  Re: [PATCH 4.9 00/44] 4.9.16-stable review Guenter Roeck <linux@roeck-us.net> - 2017-03-16 23:40 +0100

csiph-web