From: Stephen Hemminger <shemminger@vyatta.com>
To: Greg Thelen <gthelen@google.com>
Cc: Stephen Hemminger <shemminger@linux-foundation.org>,
netdev@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sky2: avoid using uninitialized variable
Date: Tue, 14 Jun 2011 00:02:30 -0400 [thread overview]
Message-ID: <20110614000230.4166a1ae@s6510.ftrdhcpuser.net> (raw)
In-Reply-To: <BANLkTi=jw5=9LcwxnXW6xNkF4RbFhHaB55Au=oDhn1yYWf53dA@mail.gmail.com>
On Mon, 13 Jun 2011 17:34:00 -0700
Greg Thelen <gthelen@google.com> wrote:
> On Mon, Jun 13, 2011 at 3:12 PM, Stephen Hemminger
> <shemminger@vyatta.com> wrote:
> > On Mon, 13 Jun 2011 14:21:59 -0700
> > Greg Thelen <gthelen@google.com> wrote:
> >
> >> 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>
> >
> > Shouldn't the callers be changed to check rather than just returning
> > 0 and masking the problem.
>
> I agree that the right long term solution is to plumb the error
> handling up through the callers. This would involve deleting the
> error-free gm_phy_read() routine and replacing all calls to it with
> calls to error-capable __gm_phy_read(). This would require converting
> several routines from returning void to returning int allowing errors
> to propagate upwards. Notable affected routines include:
> sky2_phy_power_up(), sky2_wol_init(), sky2_phy_power_down(),
> sky2_hw_down(), sky2_mac_init(), sky2_hw_up(), sky2_phy_intr(),
> sky2_led(). sky2_restart() would likely have to re-queue the work
> item in the case of failure. Presumably sky2_poll() would return 0 if
> error is seen. On a related note, it also seems that gm_phy_write()
> callers should be checking its return value to also handle the same
> class of I/O errors. Testing these changes would involve injecting
> error values or access to certain kinds of broken hardware.
In my experience if phy reads once successfully, it is going
to read every time. If there is a problem it only happens on
the first access (powered off, bad timing, etc).
> For the short term I figured that not consuming random data was a step
> in right direction. But I understand if you prefer to hold out for
> the complete solution. Unfortunately, I do not currently have time to
> contribute to the complete solution.
next prev parent reply other threads:[~2011-06-14 4:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-13 21:21 Greg Thelen
2011-06-13 22:12 ` Stephen Hemminger
2011-06-14 0:34 ` Greg Thelen
2011-06-14 4:02 ` Stephen Hemminger [this message]
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=20110614000230.4166a1ae@s6510.ftrdhcpuser.net \
--to=shemminger@vyatta.com \
--cc=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®