From patchwork Fri May 14 08:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 438824 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp119764jam; Fri, 14 May 2021 01:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyof5fPr4GYqa+8GAhmwHtB8hbok6bi7Zf33gXlk1uesut/rQ7A3p91JFajWiW2Y60NPj32 X-Received: by 2002:a05:6402:515:: with SMTP id m21mr54960053edv.117.1620979999270; Fri, 14 May 2021 01:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620979999; cv=none; d=google.com; s=arc-20160816; b=HQJ9UQYA7bFX3NclShj+UgdOMYU9Q3e/qYKxcWXIE/EhOMmlTlm3QZjGEK/UbP39x5 ORACE9nLCTkFW/cpjV0zZIcOjXlN9sRU45BBdAc4Ep/5051ZEI45ih3lmcPD7x5OApc3 a711sDBWVfMyBMQcRyebSttcaHXYhkLo3/zW22ecZ4hQAZFMH9fIJ/5RyUYNdudM0o/v OQjEIfNN9sZuEkxyfYhozp8Z3mKOHtSJbQp36UeGp7SR4YSA2Z/dfTADdTQnapLw268/ job47r6AVmfxNCD4psRvOOHKEwNmmSBTxyzPvj0x9cZjlZp7hk6N/YRZgIlYDXaRN3CX KoTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=iMt/sL+tZcYTrbXAL0Zn/ZDw3uVL9c+xB6KSbjhFx2c=; b=ejPehvQBzx3JDJrwH3sVELRTZtd29kjvxZ8ju+2e6tQWVDPHtQqQe0tk4B8PG4xFMw +smh39IJCGcDg3J4cPsqud8crUCxyxAlCGGYl7Q8qsGntpldofVXisBsQGOHqGIr9wU+ MBEeFTo5UOka7ysF70Mp/WsrJKMa99m3Ic1KziiPMoGRyI0+NMva5LMiRCXtw84T5C+X kTRs+Tqi0LLp+ZdKlQUh/pIV92oUI4V8DbmC5ErMDzuySRn8Sg8Q+/2q+JirE8EU/X8t wn1+5yhs30OMgzlkZX6Mi+g6YRF3lZYSBsjVF2LW2Id7LQCRdD1hh13tAq998/tnr9CW IFag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si5362233edi.208.2021.05.14.01.13.19 for ; Fri, 14 May 2021 01:13:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbhENIO3 (ORCPT ); Fri, 14 May 2021 04:14:29 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3685 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhENIO2 (ORCPT ); Fri, 14 May 2021 04:14:28 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FhLn651d3z1BMBM; Fri, 14 May 2021 16:10:34 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.177.72) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Fri, 14 May 2021 16:13:07 +0800 From: Zhen Lei To: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , "James E . J . Bottomley" , "Martin K . Petersen" , Nagalakshmi Nandigama , James Bottomley , MPT-FusionLinux , linux-scsi CC: Zhen Lei Subject: [PATCH 1/1] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Fri, 14 May 2021 16:13:00 +0800 Message-ID: <20210514081300.6650-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.177.72] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When an expander does not contain any 'phys', an appropriate error code -1 should be returned, as done elsewhere in this function. However, we currently do not explicitly assign this error code to 'rc'. As a result, 0 was incorrectly returned. Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS") Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.26.0.106.g9fadedd diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index d00aca3c77cec22..a5f70f0e0287147 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -6884,8 +6884,10 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) handle, parent_handle, (u64)sas_expander->sas_address, sas_expander->num_phys); - if (!sas_expander->num_phys) + if (!sas_expander->num_phys) { + rc = -1; goto out_fail; + } sas_expander->phy = kcalloc(sas_expander->num_phys, sizeof(struct _sas_phy), GFP_KERNEL); if (!sas_expander->phy) {