From patchwork Mon Jul 12 06:12:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 473062 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2718206jao; Mon, 12 Jul 2021 01:17:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy00suZqxMZVbW41hHXlt0EbUynf0JpbCRzhO27i2tkupCj92gcc2c1vyio+FJWJKk8B1X0 X-Received: by 2002:a17:906:8683:: with SMTP id g3mr32876724ejx.126.1626077837809; Mon, 12 Jul 2021 01:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626077837; cv=none; d=google.com; s=arc-20160816; b=LPAcKk/3FiES57OTRbZqHzWHCt47MlvKJ/mwV1U9tHUE+guLDLUoTPU9lUdTXIMcBT Gf1WfX61+To2S9681vxA+ucAJgu4QCbjGYAF6BVNN+RGfOnYTKyI0jE2QXvp3BeDUeFj mFr9BpSNoe4DlVQ8gmRxAQcWzBX1Z+xzohgRSCgd1EohIi12SOTe4fR3Sse67hUfS9NZ gEPIlP1ye3MKVJ6QaM0oGTSNcAiCUhf4v9nkZYs+q62UKdfMTXfUJmFHaNL38bjZ1KJG e0WU3oGS+sydDB8skGTvPpWft/U4RkUort7DBIwWjsYibtGsj6WZNudOhvtnWCbKhhFF PJZg== 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=/Tr4FcWfQZn7Ne3hnf7wv8+rpTd43iPgb3vYTMrwGVw=; b=N36Jm1S0vlg6ReKda5/euRtpzuEf0qDvE9lwKtKFzDpDHfyyVrhHgeTg5y3soHHnmP +w6SBcjSnndydkF8V5ugTVxp2dzy3N/MoFfVvUR/5LSw4vlE95GSCzAe+SlCMgpDeu2o AGFAp7pa7nReZuQPGnfRMgJiWjDtAGfCnHaTnSNU7Dqd1AKiBK5/S/pIlfs96k0a4NkV nceSUDQjkgEIIPTLiUpIX4R0oksPaPEqA0iLdV7yyDITyCzlVl3McMtuCB8t/710bQ5/ Y47xvpM7u39RKREAeUqQnxbNFnGuXXRyJQrh5sWNkt7pfn6mAaZE813a1Hl2Ix2rP/Eg Y59w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sdl2Elwt; 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 n21si13642925eda.13.2021.07.12.01.17.17; Mon, 12 Jul 2021 01:17:17 -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=sdl2Elwt; 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 S231721AbhGLILF (ORCPT + 12 others); Mon, 12 Jul 2021 04:11:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:56278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353761AbhGLICu (ORCPT ); Mon, 12 Jul 2021 04:02:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A93AD61930; Mon, 12 Jul 2021 07:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626076645; bh=hqfDGKAdTtoWtw7NqFsuUYlVAcVneAVmKwumWSlcGzg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sdl2ElwtfjL5nP6c86R8cm20ByUgYu9BTBA34f2CKW7HCJBgmzSGS6mV9XfRurS3t 0Yp9K5dpnZJlPzoTmpapTx/3xYjjKoS4nb0KGX6oFti0nisAIRBx/6V1S4MC/N/FTy UtU4W4QwsrsEJOiAal+42SgEM1k45GJW63zzVJTE= 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.13 731/800] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Mon, 12 Jul 2021 08:12:34 +0200 Message-Id: <20210712061044.551240391@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@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 d00aca3c77ce..a5f70f0e0287 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) {