From patchwork Thu Dec 14 16:58:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhipeng Lu X-Patchwork-Id: 178816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8690741dys; Thu, 14 Dec 2023 08:59:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHP/hzT2dmnL3h26IJW3o3NfEqa6d3pm566hdQta6KsZ1rjkX9xVy+833dtOHLBP1RwLJQ+ X-Received: by 2002:a05:6a00:844:b0:6ce:4ed9:bd21 with SMTP id q4-20020a056a00084400b006ce4ed9bd21mr6560876pfk.9.1702573172818; Thu, 14 Dec 2023 08:59:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702573172; cv=none; d=google.com; s=arc-20160816; b=VWQYb1ZTIUfBpbFhJBR/ffCw+0dcFswio5xAXDLwOtTD5B+EeWrm6zRKUp9VFPfWb3 PQLrV+ZtydPT2W81FwrmkJuF1CAkhhKuzxUxV1hQRQU091BGMe+Ilt/kU1LoIQ1YzXa0 YvNEo+wsyG1MzLdM61Swln7KGBDzB8LLBgf0xlQgezPyp/Xp+hAZwBs4Ch5MUOKehaLS fZ5tLe5OuXgmEvuZyzgKljxXEZ6HkZhCnHFvVNfnnlZDdp+Fdaj1LH9NnFFbGDojY8j5 y2ha2Pk19kMjwGLSbwpP6e4NLgBwTxjk6KrToq5f4uXIiRo5cxLpQkBMqiitNOsoJhrX HeCw== 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=E/JSrWSwSrMpgbF93bTg0KGkH4XDDTapvW1JTF7OBPo=; fh=Qr06Jl2SmKGxHywo38i+7SMfJrvy26lA47OMIQO+MBc=; b=L78cdyeNmedDd7huDyggegE5Kobbiy2VSHxKhQU6ongDTiP8mPCP9n8rCN06HBXILZ 9xQ+TmOpGLrBFAe80t7wRRbDt35BqfRB1DbNIo4jQWKm2bVukQcjosw4hvFima+gH/In EcjtL47NdRFrPxXWvosHr7cYC/7ERpavGFRnQ8GhaosE8yUWm0mN0B7+P3XfFrM9YTPE /qQFFOkLJgBT6wbcBYPmBe15UWzSti0XTi+zkTG5M5Lw2kCgb5C1hGr/19XRcdkQKFYu 6TVYtbXHT3M4pd533GjcFbFt0ry3eJyRlaOk57jwdmifhAhouGCwhBCxlOXokU+RLDdt qKZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id o14-20020a63e34e000000b005c6259da615si11279744pgj.271.2023.12.14.08.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:59:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 5897D836B4E9; Thu, 14 Dec 2023 08:59:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443599AbjLNQ7D (ORCPT + 99 others); Thu, 14 Dec 2023 11:59:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443568AbjLNQ7B (ORCPT ); Thu, 14 Dec 2023 11:59:01 -0500 Received: from azure-sdnproxy.icoremail.net (azure-sdnproxy.icoremail.net [207.46.229.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2005D8E for ; Thu, 14 Dec 2023 08:59:06 -0800 (PST) Received: from luzhipeng.223.5.5.5 (unknown [115.200.224.93]) by mail-app4 (Coremail) with SMTP id cS_KCgBnbDRSNHtlxiSWAA--.37213S2; Fri, 15 Dec 2023 00:58:58 +0800 (CST) From: Zhipeng Lu To: alexious@zju.edu.cn Cc: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpu/drm/radeon: fix two memleaks in radeon_vm_init Date: Fri, 15 Dec 2023 00:58:42 +0800 Message-Id: <20231214165843.3484373-1-alexious@zju.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: cS_KCgBnbDRSNHtlxiSWAA--.37213S2 X-Coremail-Antispam: 1UD129KBjvdXoWrtrWrGF4rtFyDXF45Zr4UCFg_yoWktrX_uF 18XasrJa4Dta4kZ3W7Z3Z7Zr92g3y0gw4rtrW8Kr1ft34xX3W8uFy3WFn5Xw45Wa13JFn8 Cr4vqa4fCrsrGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbc8FF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j 6F4UJwA2z4x0Y4vEx4A2jsIE14v26F4UJVW0owA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r1l 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F 4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY 6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU838nUUUUU 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 14 Dec 2023 08:59:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785277367423389061 X-GMAIL-MSGID: 1785277367423389061 When radeon_bo_create and radeon_vm_clear_bo fail, the vm->page_tables allocated before need to be freed. However, neither radeon_vm_init itself nor its caller have done such deallocation. Fixes: 6d2f2944e95e ("drm/radeon: use normal BOs for the page tables v4") Signed-off-by: Zhipeng Lu --- drivers/gpu/drm/radeon/radeon_vm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index 987cabbf1318..c38b4d5d6a14 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c @@ -1204,13 +1204,17 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm) r = radeon_bo_create(rdev, pd_size, align, true, RADEON_GEM_DOMAIN_VRAM, 0, NULL, NULL, &vm->page_directory); - if (r) + if (r) { + kfree(vm->page_tables); + vm->page_tables = NULL; return r; - + } r = radeon_vm_clear_bo(rdev, vm->page_directory); if (r) { radeon_bo_unref(&vm->page_directory); vm->page_directory = NULL; + kfree(vm->page_tables); + vm->page_tables = NULL; return r; }