[PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

STALE6918d

11 messages, 3 authors, 2007-09-06 · open the first message on its own page

[PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Satyam Sharma <hidden>
Date: 2007-09-03 22:03:03

drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function

is a genuine bug. The function returns an uninitialized value of 'err'
back to the caller, which expects it to be 0 for success cases. Let's
fix this by explicitly initializing 'err' to zero.

Signed-off-by: Satyam Sharma <redacted>

---

 drivers/net/3c59x.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
--- linux-2.6.23-rc4-mm1/drivers/net/3c59x.c~fix	2007-09-04 03:29:40.000000000 +0530
+++ linux-2.6.23-rc4-mm1/drivers/net/3c59x.c	2007-09-04 03:30:08.000000000 +0530
@@ -1492,7 +1492,8 @@ vortex_up(struct net_device *dev)
 	struct vortex_private *vp = netdev_priv(dev);
 	void __iomem *ioaddr = vp->ioaddr;
 	unsigned int config;
-	int i, mii_reg1, mii_reg5, err;
+	int i, mii_reg1, mii_reg5;
+	int err = 0;
 
 	if (VORTEX_PCI(vp)) {
 		pci_set_power_state(VORTEX_PCI(vp), PCI_D0);	/* Go active */

[PATCH -mm 2/2] 3c59x MAINTAINERS

From: Satyam Sharma <hidden>
Date: 2007-09-03 22:09:51

Remove duplicate entry for the same driver.

Signed-off-by: Satyam Sharma <redacted>

---

 MAINTAINERS |    6 ------
 1 file changed, 6 deletions(-)
--- linux-2.6.23-rc4-mm1/MAINTAINERS~fix	2007-09-04 03:49:16.000000000 +0530
+++ linux-2.6.23-rc4-mm1/MAINTAINERS	2007-09-04 03:49:28.000000000 +0530
@@ -104,12 +104,6 @@ M:	klassert@mathematik.tu-chemnitz.de
 L:	netdev@vger.kernel.org
 S:	Maintained
 
-3C59X NETWORK DRIVER
-P:	Steffen Klassert
-M:	klassert@mathematik.tu-chemnitz.de
-L:	netdev@vger.kernel.org
-S:	Maintained
-
 3CR990 NETWORK DRIVER
 P:	David Dillow
 M:	dave@thedillows.org

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Steffen Klassert <hidden>
Date: 2007-09-04 08:16:21

On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
is a genuine bug. The function returns an uninitialized value of 'err'
back to the caller, which expects it to be 0 for success cases. Let's
fix this by explicitly initializing 'err' to zero.

Signed-off-by: Satyam Sharma <redacted>
Acked-by: Steffen Klassert <redacted>

Re: [PATCH -mm 2/2] 3c59x MAINTAINERS

From: Steffen Klassert <hidden>
Date: 2007-09-04 08:25:30

On Tue, Sep 04, 2007 at 03:52:50AM +0530, Satyam Sharma wrote:
Remove duplicate entry for the same driver.
This is -mm specific. Andrew did not remove the add-3c59x-maintainer
patch after pushing it to mainline. This can be fixed just by removing
the add-3c59x-maintainer patch from -mm. 

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Satyam Sharma <hidden>
Date: 2007-09-04 08:27:10

Hi Steffen,


On Tue, 4 Sep 2007, Steffen Klassert wrote:
On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
quoted
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
Hmm, the .config I built with had PCI=y as well. Probably a compiler
version difference -- Jeff also mentioned yesterday that some newer
GCC versions fail to warn about uninitialized variables cases.

quoted
is a genuine bug. The function returns an uninitialized value of 'err'
back to the caller, which expects it to be 0 for success cases. Let's
fix this by explicitly initializing 'err' to zero.

Signed-off-by: Satyam Sharma <redacted>
Acked-by: Steffen Klassert <redacted>

Thanks,

Satyam

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Mark Hindley <hidden>
Date: 2007-09-04 08:55:09

On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
Hi Steffen,


On Tue, 4 Sep 2007, Steffen Klassert wrote:
quoted
On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
quoted
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
Hmm, the .config I built with had PCI=y as well. Probably a compiler
version difference -- Jeff also mentioned yesterday that some newer
GCC versions fail to warn about uninitialized variables cases.
Sorry, this is my bad. I have just checked: there is no warning with gcc
4.2 or 4.1, but 3.3 emits the warning. 
quoted
quoted
is a genuine bug. The function returns an uninitialized value of 'err'
back to the caller, which expects it to be 0 for success cases. Let's
fix this by explicitly initializing 'err' to zero.

Signed-off-by: Satyam Sharma <redacted>
Acked-by: Steffen Klassert <redacted>
Acked-by: Mark Hindley <redacted>

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Steffen Klassert <hidden>
Date: 2007-09-04 09:18:19

On Tue, Sep 04, 2007 at 09:53:31AM +0100, Mark Hindley wrote:
On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
quoted
Hi Steffen,


On Tue, 4 Sep 2007, Steffen Klassert wrote:
quoted
On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
quoted
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
Hmm, the .config I built with had PCI=y as well. Probably a compiler
version difference -- Jeff also mentioned yesterday that some newer
GCC versions fail to warn about uninitialized variables cases.
Sorry, this is my bad. I have just checked: there is no warning with gcc
4.2 or 4.1, but 3.3 emits the warning. 
The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
without PCI support. In this case I get

drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
                                         ^^
So we have to be more carefull with the newer gcc versions.

Steffen

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Mark Hindley <hidden>
Date: 2007-09-04 09:35:28

On Tue, Sep 04, 2007 at 11:17:57AM +0200, Steffen Klassert wrote:
 
The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
without PCI support. In this case I get

drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
That should be fixed by Satyam's patch too.

Mark

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Steffen Klassert <hidden>
Date: 2007-09-04 09:39:52

On Tue, Sep 04, 2007 at 10:35:10AM +0100, Mark Hindley wrote:
On Tue, Sep 04, 2007 at 11:17:57AM +0200, Steffen Klassert wrote:
 
quoted
The only warning that I was able to trigger with gcc 4.2 is in the case of a .config
without PCI support. In this case I get

drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1672: warning: 'err' is used uninitialized in this function
That should be fixed by Satyam's patch too.
Yes, of course.
This was just to point out what's  possible to trigger with a newer gcc and what's not.

Steffen

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Satyam Sharma <hidden>
Date: 2007-09-06 09:43:14


On Tue, 4 Sep 2007, Mark Hindley wrote:
On Tue, Sep 04, 2007 at 02:09:47PM +0530, Satyam Sharma wrote:
quoted
Hi Steffen,


On Tue, 4 Sep 2007, Steffen Klassert wrote:
quoted
On Tue, Sep 04, 2007 at 03:45:55AM +0530, Satyam Sharma wrote:
quoted
drivers/net/3c59x.c: In function 'vortex_up':
drivers/net/3c59x.c:1495: warning: 'err' may be used uninitialized in this function
This came in with the recently applied 3c59x-check-return-of-pci_enable_device patch
from Mark Hindley. I just compiled it on a PCI only machine so far, therefore I did
not notice the warning yet.
Hmm, the .config I built with had PCI=y as well. Probably a compiler
version difference -- Jeff also mentioned yesterday that some newer
GCC versions fail to warn about uninitialized variables cases.
Sorry, this is my bad. I have just checked: there is no warning with gcc
4.2 or 4.1, but 3.3 emits the warning. 
This is a GCC bug (regression, actually, as you've found out) -- no two
ways about it. Although different from the kind Jeff mentioned couple days
back -- that was about wising GCC up to false positives and /not/ emitting
warnings. But here a genuine problem was not complained about, so this is
more serious. Do you plan to open up a bug at gcc.gnu.org/bugzilla/ ?


Satyam

Re: [PATCH -mm 1/2] 3c59x: Fix uninitialized variable bug

From: Mark Hindley <hidden>
Date: 2007-09-06 21:40:43

On Thu, Sep 06, 2007 at 03:25:55PM +0530, Satyam Sharma wrote:
 
This is a GCC bug (regression, actually, as you've found out) -- no two
ways about it. Although different from the kind Jeff mentioned couple days
back -- that was about wising GCC up to false positives and /not/ emitting
warnings. But here a genuine problem was not complained about, so this is
more serious. Do you plan to open up a bug at gcc.gnu.org/bugzilla/ ?
Yes, I have just narrowed down a test case, which is remarkably simple!

int 
main(int i)
{
  int err;
    
  if (i) {
    err = 1;
  }
  return err;
}

Mark
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help