From patchwork Mon Jul 12 06:11:58 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: 472991 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2684619jao; Mon, 12 Jul 2021 00:26:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9tcB9RnatyNsS/vmxtO5tgpm/fSfbZAKCR6zOEd4vEs9CWQ7xnwPLt3pYT/1USGaUrfqI X-Received: by 2002:a17:906:3acb:: with SMTP id z11mr28309354ejd.0.1626074765979; Mon, 12 Jul 2021 00:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626074765; cv=none; d=google.com; s=arc-20160816; b=OwfTPGjldg1Qp+Nnnh1BRwJdKu6sAKmsDJy4dzF/+/LsKw/wTjKyDCpF2hHUTtBJaF 0TkGLgUlUAEv9+N9zm8cMd1MULTqqR4yg5dQIlFPUtIWB8cTZrtjQviUOQiQPZlz24IP vmdOsaNTIfim7byes1gb6n4Q8DchG1Zdn1GiFFjcM7dlsEKcqRM4GksW2WDeaUimTe5v 8ZBHIwWj136uWj+rkXVhMbLlrwb6S+aq2+06np8jOxz03/Y2uZLdmuAVag0N1du031ue CJGk/VErmMvUYUX/+fqsC3mb2JmjcV31EqQBYlQ6rXbwCf7l596t51qw0HBKQqMtWw3N EgMQ== 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=54J0n+btVPX79Rj4w6E8abgvKs9sFWZefMbvLkyJY+0=; b=uAcZNx4iW9RnY1lJfxbizWux/ZgJRZH2FYARDTUvITluBycOz0Joe3TB/s9Q1TP3J9 sr1VYMBXF/jbc8QaSjAkNq/JKT1g3Fndm8qWbms3pRw1X46RXXJrXi2uDEBmXRCxzg75 e94jkI7HYYYPinY1hjH2l8mytn0n+PG2zCS3wK51xZ7zTwcAhdiKyBUWH22WqYgm0IWZ C6QQsD7Bw0Yfh0gBhuSiV/BFWiYHouNcnV5jy1rVBFT7x2NwyjpX+7sKQ8qOitrEDqTB vfvIhRHI9RlLGGe1ky/XaF1lzlVtTHhCyFyUJhPNTfe+ReZ6bemFZ2SMCbxkafy8KX6I wNWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=quP1xfwo; 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 e9si16596658edv.146.2021.07.12.00.26.05; Mon, 12 Jul 2021 00:26:05 -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=quP1xfwo; 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 S1343723AbhGLH2s (ORCPT + 12 others); Mon, 12 Jul 2021 03:28:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:32988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245498AbhGLH1J (ORCPT ); Mon, 12 Jul 2021 03:27:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B514061221; Mon, 12 Jul 2021 07:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626074600; bh=tqny+4dDP+UDnNDW3XHLKCXwa3ZCi57AIDTxHNSfd0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=quP1xfwoXuAuAbZrGr/EHMfTWXKf1hFXHLDylB8PgKpZOio7P0Owr7ysQzx/fZwEk CWWYWi7KA7m6TiVZk6eSpKPLHFUMV9tCxpnexFhPs8zHAeH8amviSZFz6VZrGy3xgW 6wMW1dgZlXdeSB7bc6o4bRzXDcl7RvhRLOubK7Zg= 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.12 635/700] scsi: mpt3sas: Fix error return value in _scsih_expander_add() Date: Mon, 12 Jul 2021 08:11:58 +0200 Message-Id: <20210712061043.398508643@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 ae1973878cc7..7824e77bc6e2 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -6883,8 +6883,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) {