From patchwork Mon Jun 13 21:21:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Thelen X-Patchwork-Id: 100181 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E5297B6F9B for ; Tue, 14 Jun 2011 07:23:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754057Ab1FMVWo (ORCPT ); Mon, 13 Jun 2011 17:22:44 -0400 Received: from smtp-out.google.com ([216.239.44.51]:58778 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751956Ab1FMVWn (ORCPT ); Mon, 13 Jun 2011 17:22:43 -0400 Received: from wpaz37.hot.corp.google.com (wpaz37.hot.corp.google.com [172.24.198.101]) by smtp-out.google.com with ESMTP id p5DLM5sB028533; Mon, 13 Jun 2011 14:22:05 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1308000125; bh=OV+YwVNwudG0uZo03EOV6h/4xdI=; h=From:To:Subject:cc:Date:Message-ID:MIME-Version:Content-Type; b=wQxhFsGtQB3eXPrc3ijKb407RZ4blu7urHlBfqjU3UeRFfBuEQ7TyFbsbYtmcH4cI ehLBMsY3Vt+RIjcH4LG9Q== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=from:to:subject:cc:date:message-id:user-agent: mime-version:content-type; b=yDdu7qwT96VhXrbQpNFNRkUdMSOV4omL24YbfDLoiJAndzMiISBw8yCqE/5ZessSC MUYXHRj4kq/QQyQGKEV4w== Received: from gthelen.mtv.corp.google.com (gthelen.mtv.corp.google.com [172.18.96.19]) by wpaz37.hot.corp.google.com with ESMTP id p5DLLxHp029094; Mon, 13 Jun 2011 14:22:00 -0700 Received: by gthelen.mtv.corp.google.com (Postfix, from userid 104648) id 8CDAB103760; Mon, 13 Jun 2011 14:21:59 -0700 (PDT) From: Greg Thelen To: Stephen Hemminger Subject: [PATCH] sky2: avoid using uninitialized variable cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 13 Jun 2011 14:21:59 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 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 --- 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; }