Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2931251iog; Mon, 20 Jun 2022 07:44:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sgplCfBBQt13lL3OlHF2G0DP4rvMMJa2yjJvM8ZoHY/JrmfvpM4WPCrhIFSJ/AGdiwNC1Z X-Received: by 2002:a05:6a00:cca:b0:51b:ed40:b08a with SMTP id b10-20020a056a000cca00b0051bed40b08amr25057317pfv.19.1655736263146; Mon, 20 Jun 2022 07:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736263; cv=none; d=google.com; s=arc-20160816; b=WKw8w1oCbPONWUHMWgvFvG3RSWfGjiIR/8GdIEbPtXlPRVwwLvVW/cl+38oUo9Q5tQ UJqg8i5euZGuTbptkvOrWouA7ayPHY86Czc6OTTuDjY+mIYxTF7eBdxZjd+oLmanuiCI 7y1ONATitAelgFqKr7YRcf+zA8cSE91gWxUGwPyw69IYjA5RGZhasjlZ4Ad3JZttmOHc h9Wc+MQ689OoakK7+lBuyOMCiYVyc17DgGlXJnsHNIOyy+WeSkIaWd8axLdWo+UYlLfJ c/tQI9BE1oKbqEtA18cnbaCZp9QCcsF1Wc/zyfAQe9tZrLoG6HXQAU+kAxUk1wUi45Rn Yluw== 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=xD82FFRzsn7x2O/s/i9XoeMP7cu5GJi8hIjDPxlwJk0=; b=VuFme3k9kcd28MxZsmyTCPhShLlRsM/k6DExF3KD8cpOwTYtwrD9AH/I14m7YenWpY wZFvuISfM7rS/0wwpik0wVOC3xRS2iADu63aYiRMsmxBCvE4WYPLmG2iNsG1JYrIpg4v IrMckKaNIbZeHOYZKHLE2FQwFR5s/3bI7xN3upY0XHVI2DxLqT9TOgxkzJjWyaD9aqqs qaOCOXQ72xFCY1YRCUV8RwjX1J1DoAG4J9sYG9gOt3ZfmRqswShf3l2npJY7o+lmfBI3 v7kLhYi+h0eDZgNkP1SjuGQqiKWkQiZlr6NUb5AM1wFyfwzls8wAqqb6ccYqKjhcrbeI IgHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O53IY7PM; 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 a28-20020a631a5c000000b003fde9094ba3si15884917pgm.757.2022.06.20.07.44.11; Mon, 20 Jun 2022 07:44:23 -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=O53IY7PM; 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 S242326AbiFTOBF (ORCPT + 99 others); Mon, 20 Jun 2022 10:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347221AbiFTN5t (ORCPT ); Mon, 20 Jun 2022 09:57:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 346E022BCA; Mon, 20 Jun 2022 06:23:39 -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 67A1960EC7; Mon, 20 Jun 2022 13:23:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC77C3411B; Mon, 20 Jun 2022 13:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731402; bh=M2xov3M5nLHIGiZU6LE/7jpo9MVr/0vDcs2PNZ97I9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O53IY7PMw+X7S++SSUCpDxPrrRGSR2NewZ+1BkohWc24pb1b4eZU4DIrEjsPQOWLO fBhqaDg01whgeqjXufd8p3N7SgD8msB2LgmHyr+abmpkGg6M9FeqWTXuyXu5/X4VKE CRGPMJ1euz4LJhq6zDXrIWOQ/aV+Lu+AlAzHbyGc= 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 5.4 196/240] scsi: ipr: Fix missing/incorrect resource cleanup in error case Date: Mon, 20 Jun 2022 14:51:37 +0200 Message-Id: <20220620124744.665480947@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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 7a57b61f0340..a163fd9331b3 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -9772,7 +9772,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, @@ -10045,7 +10045,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