From patchwork Mon Jul 19 14:50:38 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: 479941 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4241115jao; Mon, 19 Jul 2021 08:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoHdaTND0Buy9Vv+/ycUBZtsh6g1JPw+waqGHfoBMukzgPzOUN/Qka52mqcRNqXw+RINyB X-Received: by 2002:a02:956a:: with SMTP id y97mr22213339jah.58.1626708733859; Mon, 19 Jul 2021 08:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708733; cv=none; d=google.com; s=arc-20160816; b=UH+otV5pbzEqqKnGhBmHJ1+4ddyDf4poiOmOKwkuBsLx1rwSQVfgklEga0EE3GMk3c WnMKeoNsCxeUGLNM6cVWzTx2xee+t4QCPI/Qg+m4rFDq6sUaBmi+/O/9hLwOMbVBw46m 41RshU28Cnjwm3mY+BkP2CkxthcH/k3RNCyny+FLmqqczrfOXyxsB/j74hk5ScrmJDZE Lcqv9uoeYTzo6hGpnnN1YzQGciRjlpoN1D86fnkMCev93Tp0/M8vJDBHt9AMh95drjHv LfB4yQbKXnt5L1Wlam2yrbz/F3F+XfgW6o0Ljk1/lkzEJZ62BEFMVZoSDqINqnk/+JDo Pu3g== 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=9aTMpiCvE6Nk4XJfY8wSM+3kbbTA0YeA4yLkba4YsQw=; b=gzFEC6FiTYi3rFQNNmWQA2srlGdB6QvuRwpS8Tx5VcLTxQb77+30Q+LQcqYo3n1V+W t8cM6YTMJgKK8tJm/Cfhcun+yJuyu55bSnKkdQBUvxwvTFz951s3HePTHYFDM6Mb3AAW a4amYIo4f+TaBqc2QipI1X4/HNlkWscbJaazQUFZtzIJkobIA8Hm2oNVNoOWM1mYef2K AHdHS+NBpU5YJYKf9PLRonMZo2CU5jrNfOA81i+g2X5j7Ci8QjTCLOflKM6z1ZHguKTq 8KyU+Nn703b43BVGufqkfyLM2VToq3h5SSdWMkgo1ddZtaBS4zp36aGw0ZvEI4OjcH9Z mBxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uHc0g96R; 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 g5si10245056ilk.74.2021.07.19.08.32.13; Mon, 19 Jul 2021 08:32:13 -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=uHc0g96R; 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 S240760AbhGSOvC (ORCPT + 12 others); Mon, 19 Jul 2021 10:51:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:60500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245440AbhGSOmQ (ORCPT ); Mon, 19 Jul 2021 10:42:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AFD976128C; Mon, 19 Jul 2021 15:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626708108; bh=OHeKcj5Y7wojStNmRsrQTDg6/hIqKU5JXWtwErSIH98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uHc0g96R5j10EqCdkI3q0RdD8CtU1BHw60w9hLQHwkeJuZwDPSQxvmfx+SlvjmK33 y/4VLn0LgowXEgzmLI+oRFJ+qXGCq++fs+wmfh6FL7v413T+iAdKRTdLpxT8Up+S2K XJ2RxxRmrQ6ZCSQzkekioAyxqphnYUw3N6EsweHM= 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.14 149/315] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Mon, 19 Jul 2021 16:50:38 +0200 Message-Id: <20210719144947.791528288@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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 400c055167b0..332ea3af69ec 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -5236,8 +5236,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) {