From patchwork Mon Jul 12 06:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 472850 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2647337jao; Sun, 11 Jul 2021 23:29:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLIrZwX/ahSHFWuBsjwkOhLVPtvs9Tvv/KVf37R8JgqRDLtbJ4MZZkZphmm8XTjLvj52ti X-Received: by 2002:a17:907:3d8a:: with SMTP id he10mr29473037ejc.16.1626071343694; Sun, 11 Jul 2021 23:29:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071343; cv=none; d=google.com; s=arc-20160816; b=w8tnRMxys9c08sCfjeVx5cTzMOdn7e0ifWRmO7t4Jm8YRdNCpTCCi/FKfuPit0IG2c yhS1PpFGjCcWKftcsspZMrydSjV3JKrRDqNO44MTbsVtaYNYByrAUacfYJzNHbGjeUmF Btu3mk2lFtriFJdS09VeapGrip9+/AJ/mzOL/g5nydrSlHedQaQSNg5H1NfdeLnNily5 0NlGGzpDSSReLfxAmGAmLiNA2gfGhg9ozK2jUF8CqZoUsN4En6Yi5IMrL2cihC7k0c3X UNOBeCsaUdPQXtMO7Z1eMKN3iaLbd3ZZWHQESCcHo8l0z5pAS9kjxJYjZf6gtVz2hYfU 9wvw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1n8KRJsemlDtDop4lL8uOaMUr3ENOhMURNInX+dKVxg=; b=XNrUg1ZrC1Opj1LSFZHTKH3tKglTYzWSRfCQkiwPNVXXTbGzSg3seK2tNijEh4L7EN Z7jlQns6JkyrZyA4lFzM5FxVMT3ykeRLFqlhFRuaEXatIVSF+aRLEp47D8oGChsKkmhu FpODRkgtvyKUzYqki8E+xUNFmG22xKo0McHqyENpgjnJF352TpKIitTwImv7TGlizN3n cdR9uH0Nxkt0RgKgqHVyvMDosCsaTQvWRHJMmWoKMthtYxpyPx1a5ZqRkuI//5Q+EErm Ivzct74dyp0vRut6J+7qyNQMUmQ+qNnWg1UzWXdJT/Vrh3Q0k8+cpqmpSevddysSt+2k KB0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hfa/9eU5"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz6si16420285ejc.610.2021.07.11.23.29.03; Sun, 11 Jul 2021 23:29:03 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hfa/9eU5"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237420AbhGLGbI (ORCPT + 12 others); Mon, 12 Jul 2021 02:31:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:46660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236149AbhGLG3q (ORCPT ); Mon, 12 Jul 2021 02:29:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B8231610FA; Mon, 12 Jul 2021 06:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071219; bh=2uo64SPfBivMp7SYwcq1CpiG9xxkg+RY/rz6P5OyaYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hfa/9eU5I5UWpCFG3dT3OzRv3koiMtU3F59FjeD0kZCc0lHulDo0hpnyBqxczs2II +GZmWAA+3MJUAifc2Iay6F6mCd0+GqDsTkt3W58aSna5OwNU+6x4fCGl155QUPPtTG 36ru0KdXQI88M05DLpDvzkO69FamI0VR6dyFG+c8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhen Lei , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 325/348] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Mon, 12 Jul 2021 08:11:49 +0200 Message-Id: <20210712060747.213171597@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zhen Lei [ Upstream commit d6c2ce435ffe23ef7f395ae76ec747414589db46 ] 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. Link: https://lore.kernel.org/r/20210514081300.6650-1-thunder.leizhen@huawei.com Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS") Reported-by: Hulk Robot Signed-off-by: Zhen Lei Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index aff630fccb07..3654cfc4376f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -5728,8 +5728,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) {