From: Greg Thelen <gthelen@google.com>
To: Stephen Hemminger <shemminger@linux-foundation.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sky2: avoid using uninitialized variable
Date: Mon, 13 Jun 2011 14:21:59 -0700 [thread overview]
Message-ID: <xr93vcw9s9zc.fsf@gthelen.mtv.corp.google.com> (raw)
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
next reply other threads:[~2011-06-13 21:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-13 21:21 Greg Thelen [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xr93vcw9s9zc.fsf@gthelen.mtv.corp.google.com \
--to=gthelen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®