Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6140806iog; Thu, 23 Jun 2022 12:11:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTNBKUeotCa95RWRQSklEQ8lX8k1vW11hapEVzJGywWZvT7bLok4r6JaOzOq3FnXXB2vhT X-Received: by 2002:a17:902:ecca:b0:16a:53a0:75 with SMTP id a10-20020a170902ecca00b0016a53a00075mr6594886plh.43.1656011498342; Thu, 23 Jun 2022 12:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011498; cv=none; d=google.com; s=arc-20160816; b=gxP865qAVn0Fvi0g0kUEREnbKEonTBMLymk+9w1JtnkpL3Ned5o19f6QKgSi03JJK9 gvUATOKHVUv2CmGIWJMAqW4IMyW3gcaSFgN83o/FnljvXNMkEbauucsVYYUcfkz6CxVq xmUrrVk0bQNRApU6mJF4EUxUum4ZYvyDcjBjN5OGrQuBB8dqVcq1OxcYLat4hfhAIc7A c3DguaXz+/TSaaO6oY972LUGCQTb9aENuPq/zn37InyIvlTfYiZlpSfaSYE7O6/xonJ3 nt+mVlyD9+YLN4gqgN+a9AI5U4t1hhIZeIjiv7zs6kOKjb1Pr3huipiLu58+LnPZ5/tN 1SJA== 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=6WC26LU+X0Z7a0WZWfXisP/lzErKQkSriZUq2doCF8o=; b=ZYuVifWqkH7M8nRvTTNq6KRBjxij5htBu2uDEMVYZakLurtGCLOL2pAq3BA03p6xjP EHwJa6l18m0kslKrnPehGzbRJiBQaLYP7tL2IyIhacxFExxy6eNkksVUs2d1OHB0pUNt XZef18lQai3i5h1k0PEPKPJqy8SxbtFSrNa8/W9/oGlo5zxScVBrKfLjcTpA/Kde7B60 JPo+ovgNALiB6nm9/WwFKNfqppkO4VEqVj4KdqFs50G/tXpTnX6L4Mpu7R3gjwS+7mAj ZDAkKBz9o7JjAFh+Y8EOJSJWBsm9gQFT0wvwLLI86PCfHSFMRnES42L4WbMYBkrWzCUS cL2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TR8QFzON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020a170902d2c600b0016223c6e629si468082plc.235.2022.06.23.12.11.26; Thu, 23 Jun 2022 12:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TR8QFzON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S234257AbiFWSQT (ORCPT + 99 others); Thu, 23 Jun 2022 14:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236563AbiFWSPl (ORCPT ); Thu, 23 Jun 2022 14:15:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9AFA828A2; Thu, 23 Jun 2022 10:21:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 843F161DC6; Thu, 23 Jun 2022 17:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52EABC3411B; Thu, 23 Jun 2022 17:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004918; bh=e+leZ6zhrBvbbyf5uKQq5Da8htGpVpjP3Bj5RpkC16U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TR8QFzONRKJCrbfMOlWP+RL3m5r7axlg7eKgk+tNcjj+YK4VsLbepTLp71Tdic1pw 5sMblV1lJY2gdsZabOO7YiHCS7YnhQyCvK6mf+pXALy0q4YF3EyIkkY7t+iJuvzN00 9NkCLQvD/78ulxN0qqdwMeYKWB/zBqKKqgvw5uVc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Brian King , Chengguang Xu , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 192/234] scsi: ipr: Fix missing/incorrect resource cleanup in error case Date: Thu, 23 Jun 2022 18:44:19 +0200 Message-Id: <20220623164348.481212950@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengguang Xu [ Upstream commit d64c491911322af1dcada98e5b9ee0d87e8c8fee ] Fix missing resource cleanup (when '(--i) == 0') for error case in ipr_alloc_mem() and skip incorrect resource cleanup (when '(--i) == 0') for error case in ipr_request_other_msi_irqs() because variable i started from 1. Link: https://lore.kernel.org/r/20220529153456.4183738-4-cgxu519@mykernel.net Reviewed-by: Dan Carpenter Acked-by: Brian King Signed-off-by: Chengguang Xu Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ipr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 1b04a8223eb0..c6cde552b995 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -9783,7 +9783,7 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) GFP_KERNEL); if (!ioa_cfg->hrrq[i].host_rrq) { - while (--i > 0) + while (--i >= 0) dma_free_coherent(&pdev->dev, sizeof(u32) * ioa_cfg->hrrq[i].size, ioa_cfg->hrrq[i].host_rrq, @@ -10056,7 +10056,7 @@ static int ipr_request_other_msi_irqs(struct ipr_ioa_cfg *ioa_cfg, ioa_cfg->vectors_info[i].desc, &ioa_cfg->hrrq[i]); if (rc) { - while (--i >= 0) + while (--i > 0) free_irq(pci_irq_vector(pdev, i), &ioa_cfg->hrrq[i]); return rc; -- 2.35.1