Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2143491iof; Tue, 7 Jun 2022 21:12:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVbA6KNad0tqi7A8abCCH9E01+6MWuj6Ja5PJGGVFD6MR78K+vL7zp9tXtgO1Zb0EC3AbQ X-Received: by 2002:a17:902:b909:b0:167:8c44:9bc1 with SMTP id bf9-20020a170902b90900b001678c449bc1mr9137103plb.47.1654661531072; Tue, 07 Jun 2022 21:12:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661531; cv=none; d=google.com; s=arc-20160816; b=H7Qbc+D32jYLjtk1hYark/DxkCwc67CVRjU/W9Zto67lS0KBzA84FFEJIlOon/B8RB +Zx1/xiH1Ds8VmWA99jiUMqScftXWn0d2phDnhAN9lge2egwvDB+o3QjWLZwR61gobRD G77as3MS8YRAJ76uFyKx4A7jzp7PrjfmT09xOplYKoh/Nqk2DBKs9RxCCs8XDGCgSupe DEWRnnB6oq/WxF+jrLYL14SPazOMmysjL74ndaS6I2vSiajIBXEH9DaVERjT6NNlPsB7 xwbFQ+hG8IMN9LHman1TuUl1lkHVpde+xMswVqcMgHPNiA8rk5VtzXpSZxailbrafcn7 K7FQ== 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=AeuvP075pkaXohWflYA9Hvu9tYjnfSsAjnEerCqcRCs=; b=Bk32hthASmS5KIgNW+MGdh3OXrS1DG0OwVl+ZjdAeNeZXiNmk8DOjh/QclO/mnaoUW BS5y0SMeXxlUsqWEiOFwczjaItibxrutpBR06PVwjVPw4oRxeuDYteg3i6rmThdHjvQk w3tDqAo61XaKJWKuykFSv14EqJkRiwWTmP7O8JSTo1XSeZvQdwLJMFEHoAg+T3+nafHd 1FCn9IqRnXqPRM4mQDGIxKU+OPvebH7n5xjoFiXg3qsoC/bgFlPePl0VAnepDTU+gvbx pT0/jE4OuHvdHj2MjkRwteISywoCSQC5eekUtZle7/u2mO3hMH5TD+y/4PUe5N+MI8gS ng8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=MPOTprpd; 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=163.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q61-20020a17090a1b4300b001d984c76f9asi25159913pjq.127.2022.06.07.21.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:12:11 -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=@163.com header.s=s110527 header.b=MPOTprpd; 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=163.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ED11B1D2AEF; Tue, 7 Jun 2022 20:43:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237680AbiFGHaV (ORCPT + 99 others); Tue, 7 Jun 2022 03:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237692AbiFGHaD (ORCPT ); Tue, 7 Jun 2022 03:30:03 -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 7155953B76; Tue, 7 Jun 2022 00:29: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=AeuvP 075pkaXohWflYA9Hvu9tYjnfSsAjnEerCqcRCs=; b=MPOTprpdboyRMepxjN7mB Jgc8l5b4Kq8IcjVZhOimD7UiJzePkbPOMiGI7Qeyg9OaJtvO+C5bYyyh+bMvyPI4 xsnWicdRW6Boz/oNJfCJztXHQ0llO5Qbhlyg5LhvSNNWfKFPq3FBaFfG+sOq+0N9 1DLXMX7aC3e0pFQmjUL0Qg= Received: from localhost.localdomain (unknown [123.112.69.106]) by smtp4 (Coremail) with SMTP id HNxpCgAn9eZo_p5itp_HGw--.8526S4; Tue, 07 Jun 2022 15:29:50 +0800 (CST) From: Jianglei Nie To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jianglei Nie Subject: [PATCH] scsi: csiostor: Fix memory leak in csio_wr_eq_destroy() Date: Tue, 7 Jun 2022 15:29:42 +0800 Message-Id: <20220607072942.431988-1-niejianglei2021@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: HNxpCgAn9eZo_p5itp_HGw--.8526S4 X-Coremail-Antispam: 1Uf129KBjvdXoWruF4fZryfJr4ftF43CFWDCFg_yoWftwc_CF 40gw42vFs8tFs7JryIk3y3ArWI9ay8WF4kuF1aqayfZ34Yqw1DKws3XF93X34kWr47AryD Ca1DZw1jyr13AjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRibAwPUUUUU== X-Originating-IP: [123.112.69.106] X-CM-SenderInfo: xqlhyxxdqjzvrlsqjii6rwjhhfrp/1tbi6w4ZjFXl16F00gAAsQ X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 mempool_alloc() allocates an element for mbp from a specific memory pool. When some error occurs, we should free this memory pool with mempool_free(). But when cbfn != NULL, the function returns 0 without freeing the mbp, which will lead to a memory leak. We can fix it by calling mempool_free() when the cbfn != NULL. Signed-off-by: Jianglei Nie --- drivers/scsi/csiostor/csio_wr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/csiostor/csio_wr.c b/drivers/scsi/csiostor/csio_wr.c index fe0355c964bc..7dcc4fda0483 100644 --- a/drivers/scsi/csiostor/csio_wr.c +++ b/drivers/scsi/csiostor/csio_wr.c @@ -728,8 +728,10 @@ csio_wr_eq_destroy(struct csio_hw *hw, void *priv, int eq_idx, return rv; } - if (cbfn != NULL) + if (cbfn != NULL) { + mempool_free(mbp, hw->mb_mempool); return 0; + } return csio_wr_eq_destroy_rsp(hw, mbp, eq_idx); } -- 2.25.1