Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3468403pxb; Mon, 4 Apr 2022 17:57:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxajUrJdSJc29o2/Tj6vrzo8uYRoz2UTXATDdT3G6z7yhn7zmc8FHee0Ea+xYx9ONHIqDLH X-Received: by 2002:a17:902:bb90:b0:156:2c05:b34f with SMTP id m16-20020a170902bb9000b001562c05b34fmr938601pls.53.1649120242856; Mon, 04 Apr 2022 17:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649120242; cv=none; d=google.com; s=arc-20160816; b=yrmEW3ooQl00v4ZjbxTXMiKZaqoCDHHtwysqqw7Dj72pXSZFygEYi799qWy4GzxM+p ek1zudcK1PidiQQovQMhrp+p3lIreSRuVQSmCh7YuGi9NYFNwHKIo6veVYon+UvcrQvA sI89tkJ+Nd7jiH3tAhewBuBDKuqFW7uSTopqYz7r86tmRn4MlhrOr45mNoj29pQwsXHA HXxlbH0DpqP4YG62WpqmEY3V/AJnkCqht8uxSjC3cEomJo7BUDJYfJqZKblPmk2C8TJ3 5I6Y61WtE4a2ERnQ95MImKHhm5hZFm62hDhg+FI2lmqKH3W2xOR4wsDRJQ5lsWiz93lR /9pA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zBdq+tZTgx2WDQAS9Wzc3LGcuGoYZEOOoECc/vqEMo0=; b=Q6SdYOIQTNczIAKNsbhlDLaHHJY3nRMsD3JjDywHFe+2FwhKCahEAykGBoW632FwaT jZRX2w357n0B2z3atF/Y3brk2uLojOlVKKXNwrkZwai+9I8Dp4TZZQuedIBGHHdTAClM 7JPfYEgWlLrfGeIyGj6yziAJ18+CU00S3aOMcR4VPBfJBTxBLLQj6CHu8EZXNCfdPD4v ULFDnLyBC52JS8BL+NKaqcW8WPdDP0GqPdrhmNNA/b80xxav3RMTxOhb2rHPE92UbHVU k73DyMxs5y0egOWRO9cQj5dBh6/7FWwrScyJfDgI9BDyPqBY8G/0YXWce3IehAfaXd8X tpMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GRiQ0PWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k5-20020aa788c5000000b004fa3a8dff68si12068140pff.31.2022.04.04.17.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 17:57:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GRiQ0PWf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C554A1342E3; Mon, 4 Apr 2022 17:04:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348522AbiDAOiV (ORCPT + 99 others); Fri, 1 Apr 2022 10:38:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347816AbiDAOde (ORCPT ); Fri, 1 Apr 2022 10:33:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39BF8287A2E; Fri, 1 Apr 2022 07:30:44 -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 ams.source.kernel.org (Postfix) with ESMTPS id DC61BB8250B; Fri, 1 Apr 2022 14:30:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89C23C340EE; Fri, 1 Apr 2022 14:30:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823441; bh=fWm4XXGJmhOWlzOrjvIifXxK5XKhN5XoL7PPRKHRvl0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRiQ0PWfPmijBzEeo0eRdNDCUz2LOYW/Ey9vrEuvTorolTJMxd1QOVOPBfGis593z lxXW4ILq/fACovNeg9Kri1GAhVFgqyv+J5rfqUig1/W0Pxd9MYboPoUfB4LLW7uvmT LX2pOCb98gMdci6MmdzKbhg+If4Aj7LVgLejLhJKbhSSFMewo8LvNFN7jqntAkhDSe 9dwRNYlK7DmpipotmX9SfPXZFGMxrHbBQecVjiZK+C/EfGHpSsHFN3RFCyc+Ep4IpC +A3txp7I7pMcve8qu/MQegi44kndQ7hq9GP7JMWxiIPC8D7ACqz0Utc/SPSlHXy7fB dGlZ58JzC3rpw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Damien Le Moal , John Garry , "Martin K . Petersen" , Sasha Levin , jinpu.wang@cloud.ionos.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.17 097/149] scsi: pm8001: Fix tag leaks on error Date: Fri, 1 Apr 2022 10:24:44 -0400 Message-Id: <20220401142536.1948161-97-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401142536.1948161-1-sashal@kernel.org> References: <20220401142536.1948161-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Damien Le Moal [ Upstream commit 4c8f04b1905cd4b776d0b720463c091545478ef7 ] In pm8001_chip_set_dev_state_req(), pm8001_chip_fw_flash_update_req(), pm80xx_chip_phy_ctl_req() and pm8001_chip_reg_dev_req() add missing calls to pm8001_tag_free() to free the allocated tag when pm8001_mpi_build_cmd() fails. Similarly, in pm8001_exec_internal_task_abort(), if the chip ->task_abort method fails, the tag allocated for the abort request task must be freed. Add the missing call to pm8001_tag_free(). Link: https://lore.kernel.org/r/20220220031810.738362-22-damien.lemoal@opensource.wdc.com Reviewed-by: John Garry Signed-off-by: Damien Le Moal Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/pm8001/pm8001_hwi.c | 9 +++++++++ drivers/scsi/pm8001/pm8001_sas.c | 2 +- drivers/scsi/pm8001/pm80xx_hwi.c | 9 +++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 1cf3878b47f3..54db341455b9 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -4462,6 +4462,9 @@ static int pm8001_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, SAS_ADDR_SIZE); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4874,6 +4877,9 @@ pm8001_chip_fw_flash_update_req(struct pm8001_hba_info *pm8001_ha, ccb->ccb_tag = tag; rc = pm8001_chip_fw_flash_update_build(pm8001_ha, &flash_update_info, tag); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } @@ -4978,6 +4984,9 @@ pm8001_chip_set_dev_state_req(struct pm8001_hba_info *pm8001_ha, payload.nds = cpu_to_le32(state); rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + return rc; } diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index c1f871561b32..b68c8400ca15 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -847,10 +847,10 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha, res = PM8001_CHIP_DISP->task_abort(pm8001_ha, pm8001_dev, flag, task_tag, ccb_tag); - if (res) { del_timer(&task->slow_task->timer); pm8001_dbg(pm8001_ha, FAIL, "Executing internal task failed\n"); + pm8001_tag_free(pm8001_ha, ccb_tag); goto ex_err; } wait_for_completion(&task->slow_task->completion); diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c index 00c95ea480ad..075061cdfe52 100644 --- a/drivers/scsi/pm8001/pm80xx_hwi.c +++ b/drivers/scsi/pm8001/pm80xx_hwi.c @@ -4901,8 +4901,13 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, payload.tag = cpu_to_le32(tag); payload.phyop_phyid = cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); - return pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, - sizeof(payload), 0); + + rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, + sizeof(payload), 0); + if (rc) + pm8001_tag_free(pm8001_ha, tag); + + return rc; } static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha) -- 2.34.1