Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2553939rdb; Mon, 4 Dec 2023 00:07:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+WwEg/305Hi50Y0L45yqyONWT1HGhEJdFiTZ6i2E6g9f0iHMIR1e8T2IrjvvPXTZ05q4h X-Received: by 2002:a05:6a00:983:b0:6cd:ed99:550b with SMTP id u3-20020a056a00098300b006cded99550bmr4519717pfg.4.1701677275623; Mon, 04 Dec 2023 00:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701677275; cv=none; d=google.com; s=arc-20160816; b=HKH5pX7RQ0gD67vCxeJorgCdrPvjWmaN5Yzlwqv7KGw00hQZoB2k85X4CyliL4Bofn BESvVEn0IYYL6iBMn+jjb5qmog6UwBIdA8zdWP/xHrrk53JlaZe1J7SV8s/YbTteF3v2 FZbUpgLgRHD4lQ4GjuarnZ4T0XBbOk8B+1z6xCoR9Vc0gK4mFSvGHgpfm0cZyOgWNx2C bLq8HnsR7rBHkG39cQ5leXRW8prMT1cqADpIh9kg3mzGohdK+wBtvxO6EPl3xJhLsF62 hbMPcOpIGP1tYeGZi0xzsiC4opjw+cpt67sYqbVBuLEaO6X/agpjYlvfiOL0EHbAdp11 f72Q== 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; bh=LX0qs8172aRk3FdDzAVeCO7aVxQIgL0RNMaA6Hvhdi8=; fh=5wn8w10TNNKg0T25di8BZvwFJVZARjawxPDr5mbd868=; b=tGMm82qkhgz29VYwMlJ7EAdziV0vfTpnJVIXhKibDDf88oeaSB6Gl7meIDjd/laPVh kLeAJTbTjcoZ8FgP/I+DKhcDYWs/eBEfc6IrucK07JLXwJFA7Qgl2n51QgzlGCczvcEC CAGFObYRHlZ0x4nlfk6QFNf03bSDh26XJ5RwV4qpk59Fzkiz3L/mdpQCvGtrQP/kmaYO VSQc8/5lkCcEPnfe1rnjEgMzh54z/AwDTtqT8MS4zU8iuKD1sHIy9tHRA3jKJT1snL4Z YAnXTd5/lObB156JziBRWPAgOhk2xoLojHJq46eIaBrDnuL2VvoF7xIxlSEvQPTY/KdT eL3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b14-20020a056a000a8e00b006cdc6987539si7596125pfl.266.2023.12.04.00.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:07:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2E518808BC90; Mon, 4 Dec 2023 00:07:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234699AbjLDIHi (ORCPT + 99 others); Mon, 4 Dec 2023 03:07:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbjLDIHc (ORCPT ); Mon, 4 Dec 2023 03:07:32 -0500 Received: from zg8tndyumtaxlji0oc4xnzya.icoremail.net (zg8tndyumtaxlji0oc4xnzya.icoremail.net [46.101.248.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E7CFA1A1 for ; Mon, 4 Dec 2023 00:07:26 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [115.200.230.188]) by mail-app3 (Coremail) with SMTP id cC_KCgCHjBmniG1lzaVqAA--.37252S2; Mon, 04 Dec 2023 16:07:04 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Zack Rusin , VMware Graphics Reviewers , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , =?UTF-8?q?Christian=20K=C3=B6nig?= , Matthew Auld , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/vmwgfx: fix a memleak in vmw_gmrid_man_get_node Date: Mon, 4 Dec 2023 16:06:46 +0800 Message-Id: <20231204080646.3299620-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cC_KCgCHjBmniG1lzaVqAA--.37252S2 X-Coremail-Antispam: 1UD129KBjvdXoWrKr48WFykJw1fJF4xAFy5Arb_yoWfurc_ua yYqrn2q3y3CFn5uw12v3sxuF42ka1fuFs7uFs3ta43J3sIv340gry7ur98Xw4xWFsrCryD Wa1UGw1fArnrKjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j 6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxkIecxEwVAFwVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x0JUhdbbUUUUU= X-CM-SenderInfo: qrsrjiarszq6lmxovvfxof0/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:07:53 -0800 (PST) When ida_alloc_max fails, resources allocated before should be freed, including *res allocated by kmalloc and ttm_resource_init. Fixes: d3bcb4b02fe9 ("drm/vmwgfx: switch the TTM backends to self alloc") Signed-off-by: Zhipeng Lu --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index ceb4d3d3b965..220561b73493 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -65,6 +65,8 @@ static int vmw_gmrid_man_get_node(struct ttm_resource_manager *man, id = ida_alloc_max(&gman->gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL); if (id < 0) + ttm_resource_fini(man, *res); + kfree(*res); return id; spin_lock(&gman->lock); -- 2.34.1