All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sky2: avoid using uninitialized variable
@ 2011-06-13 21:21 Greg Thelen
  2011-06-13 22:12 ` Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Greg Thelen @ 2011-06-13 21:21 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, linux-kernel

I am not sure if 0 or ~0 would be a better choice in the gm_phy_read()
error case.  I used 0.  A more complete solution might be to plumb up
error handling to the callers of gm_phy_read().

==
>From 37486219a3d93881f3b2619a4b2bb21be62db7d4 Mon Sep 17 00:00:00 2001
From: Greg Thelen <gthelen@google.com>
Date: Mon, 13 Jun 2011 14:09:07 -0700
Subject: [PATCH] sky2: avoid using uninitialized variable

Prior to this change gm_phy_read() could return an uninitialized
variable if __gm_phy_read() failed.

This change returns zero in the failure case.

Signed-off-by: Greg Thelen <gthelen@google.com>
---
 drivers/net/sky2.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 3ee41da..eba1ac4 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -206,7 +206,8 @@ io_error:
 static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
 {
 	u16 v;
-	__gm_phy_read(hw, port, reg, &v);
+	if (__gm_phy_read(hw, port, reg, &v) < 0)
+		return 0;
 	return v;
 }
 
-- 
1.7.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-06-17  3:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-13 21:21 [PATCH] sky2: avoid using uninitialized variable Greg Thelen
2011-06-13 22:12 ` Stephen Hemminger
2011-06-14  0:34   ` Greg Thelen
2011-06-14  4:02     ` Stephen Hemminger
2011-06-17  3:10       ` David Miller
2011-06-17  3:51         ` Ben Hutchings
2011-06-17  3:58           ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.