From patchwork Sun May 6 18:18:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 157146 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D5A97B6FB7 for ; Mon, 7 May 2012 04:02:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754543Ab2EFSC4 (ORCPT ); Sun, 6 May 2012 14:02:56 -0400 Received: from mga14.intel.com ([143.182.124.37]:41732 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754464Ab2EFSC4 (ORCPT ); Sun, 6 May 2012 14:02:56 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 06 May 2012 11:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="139523179" Received: from dwillia2-linux.jf.intel.com ([10.23.45.110]) by azsmga001.ch.intel.com with ESMTP; 06 May 2012 11:02:55 -0700 Received: from dwillia2-linux.jf.intel.com (localhost.localdomain [IPv6:::1]) by dwillia2-linux.jf.intel.com (Postfix) with ESMTP id 6043B80010; Sun, 6 May 2012 11:18:48 -0700 (PDT) Subject: [PATCH 10/18] libsas: sas_rediscover_dev did not look at the SMP exec status. To: linux-scsi@vger.kernel.org From: Dan Williams Cc: linux-ide@vger.kernel.org, Jeff Skirvin Date: Sun, 06 May 2012 11:18:48 -0700 Message-ID: <20120506181848.17912.90848.stgit@dwillia2-linux.jf.intel.com> In-Reply-To: <20120506181611.17912.3798.stgit@dwillia2-linux.jf.intel.com> References: <20120506181611.17912.3798.stgit@dwillia2-linux.jf.intel.com> User-Agent: StGit/0.16-1-g7004 MIME-Version: 1.0 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Jeff Skirvin The discovery function "sas_rediscover_dev" had two bugs: 1) it did not pay attention to the return status from the SMP task execution; 2) the stack variable used for the returned SAS address was compared against 0 without being initialized. Signed-off-by: Jeff Skirvin [djbw: todo sanitize smp_execute_task return values (see: residue)] Signed-off-by: Dan Williams --- drivers/scsi/libsas/sas_expander.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index f1e8e0a..63d3e59 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -2005,6 +2005,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) u8 sas_addr[8]; int res; + memset(sas_addr, 0, 8); res = sas_get_phy_attached_dev(dev, phy_id, sas_addr, &type); switch (res) { case SMP_RESP_NO_PHY: @@ -2017,9 +2018,13 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last) return res; case SMP_RESP_FUNC_ACC: break; + case -ECOMM: + break; + default: + return res; } - if (SAS_ADDR(sas_addr) == 0) { + if ((SAS_ADDR(sas_addr) == 0) || (res == -ECOMM)) { phy->phy_state = PHY_EMPTY; sas_unregister_devs_sas_addr(dev, phy_id, last); return res;