From patchwork Mon Jul 19 14:50:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479867 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4217242jao; Mon, 19 Jul 2021 08:11:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzMTXo1suKcRN0QM/2Qj+a1y20269Ex8U4uhQht/z5gqy4c878tu15DW3JxGKMy6JaABUP X-Received: by 2002:a5d:5141:: with SMTP id u1mr30464649wrt.193.1626707503797; Mon, 19 Jul 2021 08:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707503; cv=none; d=google.com; s=arc-20160816; b=DGuzD+KDvAhgY1GYjdfFNoBB5RqzQW6wD2b4O6t7ITN7ypIaG4nFq6uJZPJ6/iC5b1 now1IXTUKnYbHQTGqpmneHj2aqqeT8I/HfyIyNNHs43S1qxrJV1f+hVB+lJR537eydVt xMJ92iOLBQkTEox09gLInQ7Q1GQwR0MsYxH8iSaA0w3d+mLqJgXODBLMeRJcX0IOtPQ0 lpHe7EMNe2H/hrNsyfqOfj87jeCGubkNjBY2HMvtaQQ/Psla5moONmc0m2nxx+5UV4W8 tirp1ZHIi936fHnUyypccNCOgspwbWk3qgTQt2g6pljfXHfXJcOiJ/9fF+QUvDmocAlz Bp1Q== 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=0CKEtC/7NQAZi6bfbmHCBweT3psxCjCQvCflj+0yxfM=; b=Qg/wtNMrvYJVjZsjNlJ1VaKBjVSKTeG/09kaLKDsezpzvliLwAxBEEtI79FbgLD3ZA eh6g2qrsvhglnpjNiYYg7XlIzq4Ha3Fmq7V6a5bMQ/RDe/pWkB0rgmKzuOqWj/UNahbH NewMKkSwMyEjiN4oK8za1qEWHr0kQ4AFRtrG0DuSQPyn89/q5HyerypcjQss7/+X3i6p ghGu4S9fJmBgNSTkLEwRkplM2ylRUn8lB3fsC2rTHPHEIY5YkWuJodDJALAkYBImyPem UyiPO/tKJefEwrsFiH/dgIgIC5ZR7+TNBxucPJnZvNbwv4v/V3Qr4wqUsfTZp4jVOY4S V/Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VmRKVRCr; 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 d26si20449114ejc.620.2021.07.19.08.11.43; Mon, 19 Jul 2021 08:11:43 -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=VmRKVRCr; 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 S242262AbhGSOao (ORCPT + 12 others); Mon, 19 Jul 2021 10:30:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244045AbhGSO3O (ORCPT ); Mon, 19 Jul 2021 10:29:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BCBA6128A; Mon, 19 Jul 2021 15:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707322; bh=5ZDHVfW8B0AvKuteMND22zDcF8Pgi9DikFQfqF5Cwjg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VmRKVRCrIQfVLoLtBPJ+A5NoefoY0koO5gkuz5JpgemiqN9uxrTwoqjHVRU3q0TCc 8lifHiX4xwzCOedwswe5wSe6LaYsCxie7eiczDfquIls8l60sWVijFQspWX5AzOfJ/ 0mb0tKjqiYf3DvzhizUpe7FHttV5T98e6HF/QBNs= 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 4.9 114/245] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Mon, 19 Jul 2021 16:50:56 +0200 Message-Id: <20210719144944.101593110@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 aa2078d7e23e..58876b8a2e9f 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -5199,8 +5199,10 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) handle, parent_handle, (unsigned long long) 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) {