Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1797262pxb; Sat, 2 Apr 2022 04:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRFHMRkcXk9JKgyrvod+CDcb6A+25ulf6+Dp8jQ7pkHZCR+6bgSKXeRBn9jmauesqDEzoP X-Received: by 2002:a17:902:ecc6:b0:154:5393:aa98 with SMTP id a6-20020a170902ecc600b001545393aa98mr51864477plh.88.1648897355128; Sat, 02 Apr 2022 04:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648897355; cv=none; d=google.com; s=arc-20160816; b=VhuEaAlMMpPJU2qMU1I8inElqS81bgESC2LNdprKuwX0RKWh8PH1zCC6uG0zx3Rqr7 nl1d44uyFekpcRWORFk5bV88LdMiJ0p3Q+qGffKuxFEL/sr9g4IqjbLL0qb/7QetjMh7 2C78Ux2NmwXGDVbtszftyoz0tSzETEeacDrZ4XSC6xWpdxQV+mj807sBNhssZu/gRNMN 6Z9HJ4elWkyf2IB1D00E5KzmP6xvgJBDs0UK7Nx1CGWCMtuLWmM5k5F5MIe5NTQkJM1q U1NMCQG3LrvFa56LWv410625YOTIbv5lPVzNjT2MGniMTp5flaVq93OD9jjBcqkYOG5L 9McA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=qWu2VceeNu47ONpaFF+PutCfqvORqWCsrLi/LPHWaN0=; b=LV5eUqM21JXQR+T780FPVgnXiPZvwAo5EbVcYEzIBV/vXN4p6SoQR1BHISb2d7CSSc klgfs7OfcvxULJHTfe7CAnGDtYESYpuKsvfR0eDpT5CQppmoKnmJ5irNV5t3kP+m3wY7 MuUMEgkyeEuDEIVF4YD6dwDqnUNIkO8y94GNZHw3TNO6uGqjyUT7sr/+7T72+UXQAsfI ucK4KpbbIcQDDaPznlmAcAChNizvjw2jIrpmtDGLSaJ6LEmUNgngD4j6MDV+gB/S5IbN WWEWXxzDJD2prfCTeoUqO/QMZueDLl6kTrSzf0sAeHgtbU5nIhfCXYDWfZNqPltqF5Rj 8nOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=DxW1aqxl; 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=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a654345000000b003985d59194csi4741085pgq.860.2022.04.02.04.02.21; Sat, 02 Apr 2022 04:02:35 -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=@163.com header.s=s110527 header.b=DxW1aqxl; 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=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343900AbiDAHkw (ORCPT + 99 others); Fri, 1 Apr 2022 03:40:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343888AbiDAHku (ORCPT ); Fri, 1 Apr 2022 03:40:50 -0400 Received: from mail-m974.mail.163.com (mail-m974.mail.163.com [123.126.97.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85CA425E326 for ; Fri, 1 Apr 2022 00:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=qWu2V ceeNu47ONpaFF+PutCfqvORqWCsrLi/LPHWaN0=; b=DxW1aqxlu7nRMtsr9JoRU zsUvWbx03yhJ7azCdMtspQl0CPXyhL7kscFabpot5gpHKyrf+Fq0+i+bAV6yCisi 58OPyyW0PR4+jZEeG/eHu3Eht1wpeHwAkpxGD0LMKJ4I5eXh2sIBqCBS8zFErTpG AKRIS/4iy3H1GODSWPV4Bk= Received: from localhost.localdomain (unknown [218.106.182.227]) by smtp4 (Coremail) with SMTP id HNxpCgA3B7L6q0ZiLC4RAA--.2609S4; Fri, 01 Apr 2022 15:38:44 +0800 (CST) From: Jianglei Nie To: jinpu.wang@cloud.ionos.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: nlinux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] scsi: pm8001: Fix resource leak in pm8001_send_abort_all() Date: Fri, 1 Apr 2022 15:38:33 +0800 Message-Id: <20220401073833.15655-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgA3B7L6q0ZiLC4RAA--.2609S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7KF1fKF13Cw1ftF4kAF1xuFg_yoW8GF4rpr WkZr1jkF45A3ZYgwsxAanrJ3Z5t3yxK34UCFyxZw1YgFW5XrW8tFyI9rW2qr1xJ34kCF18 XryDKrnrGFyDZr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pE3Cz9UUUUU= X-Originating-IP: [218.106.182.227] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/xtbBOQTVjF-PMPcrIwAAs7 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 sas_alloc_slow_task() allocates a task in line 1774. But when pm8001_tag_alloc() or pm8001_mpi_build_cmd() fail, the allocated task is not freed by sas_free_task(), which will lead to resource leak. We can fix it by freeing the task when pm8001_tag_alloc() and pm8001_mpi_build_cmd() fail. Signed-off-by: Jianglei Nie --- drivers/scsi/pm8001/pm8001_hwi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c index 9ec310b795c3..fec5e26fbf0f 100644 --- a/drivers/scsi/pm8001/pm8001_hwi.c +++ b/drivers/scsi/pm8001/pm8001_hwi.c @@ -1781,8 +1781,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, task->task_done = pm8001_task_done; res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); - if (res) + if (res) { + sas_free_task(task); return; + } ccb = &pm8001_ha->ccb_info[ccb_tag]; ccb->device = pm8001_ha_dev; @@ -1798,9 +1800,10 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha, ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, sizeof(task_abort), 0); - if (ret) + if (ret) { + sas_free_task(task); pm8001_tag_free(pm8001_ha, ccb_tag); - + } } static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha, -- 2.25.1