From patchwork Mon Apr 2 07:10:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel J Blueman X-Patchwork-Id: 10320697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FCC160390 for ; Tue, 3 Apr 2018 07:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2751FF22 for ; Tue, 3 Apr 2018 07:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E20FB26247; Tue, 3 Apr 2018 07:17:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B3031FF22 for ; Tue, 3 Apr 2018 07:17:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A1016E35B; Tue, 3 Apr 2018 07:17:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id D2F016E0D1 for ; Mon, 2 Apr 2018 07:10:51 +0000 (UTC) Received: by mail-pl0-x243.google.com with SMTP id s24-v6so3617674plq.6 for ; Mon, 02 Apr 2018 00:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quora.org; s=google; h=from:to:cc:subject:date:message-id; bh=O+6dDHoXxVmoPuCYxWa7Mw7lgjYKXsj0E9lzQ+J6D1E=; b=CaMakeepvPs4Bugf5uIEfkqN7ABCIyhtmfIg1OfDhXoe9rACZI/i8gW8iqLToa3/a3 Xh9QBT8cNTi3LQQ8evhyLgwgVV1JAg8QpiFDzCxKRTYlYK9lXTYsC53pNdAS2UK6/Gfb sKTkT5XTCkqWy2z3LLwrSulgKY6QS51lSU6WE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=O+6dDHoXxVmoPuCYxWa7Mw7lgjYKXsj0E9lzQ+J6D1E=; b=DwLD9bNtATeGyWrcJMO1ZDY9QZFF0hAuhtTGsHjUnJwnuB4asPQLudmf0yZFJJfv7i din3IT2RTIPxUcE/0EXMM7Rv/+ICj326QBeWv9NCAFRUdBKGNXFJpsYTuFlRZ4o2LMnX 57D3ucCYXZBFFNiQW9ksl0XEJ0aotcOdK1UjDIcUvjEld6epI1NmC/OC2wbFfbH3mwnL Za4r5Cwi/ngtHo21J0ucaEGdkxRPayc2blsXQi02rlHZY9uDu05+Kp77qjMLc5ycrQsD Kbv3KbW/BGtg2CXJgpZ7eTtxBgKIssTxOp2sqjqdKj/jfAHs+9nBHDJjn5tfDbG3fLFF jUkQ== X-Gm-Message-State: AElRT7HhrIFO/JJ10+2F6P4V4y8Pm2mFqSnLda8Iy0LZB2UahQXzjxSR V7ll1AYFhHXE0AB/gQTuh/WQ2w== X-Google-Smtp-Source: AIpwx483D5/z1YbW/I1XApxQ2QgcJW47VUS49V4Jm49xdpem0llmf7TJ48Z4sQKt8xhlPsQKnWE8fg== X-Received: by 2002:a17:902:24:: with SMTP id 33-v6mr8761215pla.341.1522653051375; Mon, 02 Apr 2018 00:10:51 -0700 (PDT) Received: from localhost.localdomain ([202.83.97.154]) by smtp.gmail.com with ESMTPSA id p3sm23554254pga.45.2018.04.02.00.10.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Apr 2018 00:10:50 -0700 (PDT) From: Daniel J Blueman To: linux-kernel@vger.kernel.org Subject: [PATCH] drm/vc4: Fix memory leak during BO teardown Date: Mon, 2 Apr 2018 15:10:35 +0800 Message-Id: <20180402071035.25356-1-daniel@quora.org> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Tue, 03 Apr 2018 07:16:35 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel J Blueman , stable@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Airlie MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP During BO teardown, an indirect list 'uniform_addr_offsets' wasn't being freed leading to leaking many 128B allocations. Fix the memory leak by releasing it at teardown time. To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Eric Anholt Cc: Dave Airlie Cc: stable@vger.kernel.org Signed-off-by: Daniel J Blueman --- drivers/gpu/drm/vc4/vc4_bo.c | 2 ++ drivers/gpu/drm/vc4/vc4_validate_shaders.c | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index 2decc8e2c79f..add9cc97a3b6 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -195,6 +195,7 @@ static void vc4_bo_destroy(struct vc4_bo *bo) vc4_bo_set_label(obj, -1); if (bo->validated_shader) { + kfree(bo->validated_shader->uniform_addr_offsets); kfree(bo->validated_shader->texture_samples); kfree(bo->validated_shader); bo->validated_shader = NULL; @@ -591,6 +592,7 @@ void vc4_free_object(struct drm_gem_object *gem_bo) } if (bo->validated_shader) { + kfree(bo->validated_shader->uniform_addr_offsets); kfree(bo->validated_shader->texture_samples); kfree(bo->validated_shader); bo->validated_shader = NULL; diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c b/drivers/gpu/drm/vc4/vc4_validate_shaders.c index d3f15bf60900..7cf82b071de2 100644 --- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c +++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c @@ -942,6 +942,7 @@ vc4_validate_shader(struct drm_gem_cma_object *shader_obj) fail: kfree(validation_state.branch_targets); if (validated_shader) { + kfree(validated_shader->uniform_addr_offsets); kfree(validated_shader->texture_samples); kfree(validated_shader); }