From patchwork Fri Jul 20 14:11:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damir Shaikhutdinov X-Patchwork-Id: 10539693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 880BB17FD for ; Mon, 23 Jul 2018 07:19:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E2E02852A for ; Mon, 23 Jul 2018 07:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 613F82852E; Mon, 23 Jul 2018 07:19:39 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 207182852A for ; Mon, 23 Jul 2018 07:19:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9411C6E242; Mon, 23 Jul 2018 07:19:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by gabe.freedesktop.org (Postfix) with ESMTPS id E07B26EFF7 for ; Fri, 20 Jul 2018 14:11:49 +0000 (UTC) Received: by mail-ed1-x544.google.com with SMTP id h1-v6so9897843eds.1 for ; Fri, 20 Jul 2018 07:11:49 -0700 (PDT) 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:in-reply-to :references; bh=dP8IKTT5aEoKppP9cV5vrfsa1v8tCWTeltnlcPIlXhU=; b=KRhRh3fMdg0htLpD0oU8zl3OdITnYJx5Uiwxnjx5iNyNvMD8hjsOAedMwkL4s+vImB ULq7KA6LSNl9OHKdMt+giDRmM8JnLypI2iKTEVqnmb0zvtlpMHGvrja3z+hW8C9TVRSR TyZetsqrAfJNR41B1imlYAwfYDu0hx7bLR2Sj11Ctj32fOy/l1JNvcvAcKV39uU28JOA UiUzCmHnqhyqYlvter/xkaXw/3bXxgnd+aDB62QU6K9Y1o4K1n0LZ4lRZmw38x42XwfW HDYqs+w50CQn6fWXWeRw9yc+5ZLcNTYLxPrhG1ivAsLE5xKKyqDTr507Wj7gCRsra2hy bJZw== X-Gm-Message-State: AOUpUlFUTu1+pcRriR7uCneTda+x+9N+MgiiOnx9UecTvujixbBbigQi RR0ZuOWQDV+xU8t/3L5O5Qs= X-Google-Smtp-Source: AAOMgpcq+crRBWIPGcoUnTWlyegfexvIpxflB3AC1CPH3Dt+cxB/Nu2xOJFABIDm77GNnrJBVOkCBQ== X-Received: by 2002:a50:aca3:: with SMTP id x32-v6mr2784260edc.41.1532095908569; Fri, 20 Jul 2018 07:11:48 -0700 (PDT) Received: from os-lin-dsh.open-synergy.com ([217.66.60.5]) by smtp.gmail.com with ESMTPSA id j16-v6sm3391749edj.71.2018.07.20.07.11.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jul 2018 07:11:48 -0700 (PDT) From: Damir Shaikhutdinov X-Google-Original-From: Damir Shaikhutdinov To: aerlied@gmail.com Subject: [PATCH 1/4] drm/virtio: Fix memory leak during framebuffer destruction. Date: Fri, 20 Jul 2018 16:11:40 +0200 Message-Id: <20180720141143.15469-2-damir.shaikhutdinov@opensynergy.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180720141143.15469-1-damir.shaikhutdinov@opensynergy.com> References: <20180720141143.15469-1-damir.shaikhutdinov@opensynergy.com> X-Mailman-Approved-At: Mon, 23 Jul 2018 07:18:41 +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: Damir Shaikhutdinov , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP In function virtio_gpufb_create, a virtio_gpu_object is allocated for framebuffer using virtio_gpu_alloc_object. In virtio_gpu_fbdev_destroy, instead of freeing the object, pointer to it is set to NULL. This leads to memory leak during framebuffer destruction, which is reported to kmesg with a message like this: Memory manager not clean during takedown. With DRM_DEBUG_MM enabled, following additional information is printed about the leak: node [00100000 + 000001d5]: inserted at save_stack.isra.9+0x67/0xc0 drm_mm_insert_node_in_range+0x325/0x4f0 drm_vma_offset_add+0x46/0x60 ttm_bo_init_reserved+0x2c9/0x400 ttm_bo_init+0x2a/0x80 virtio_gpu_object_create+0x139/0x180 virtio_gpu_alloc_object+0x2f/0x60 virtio_gpufb_create+0xac/0x2a0 Correctly freeing virtio_gpu_object during framebuffer destruction fixes the issue. Signed-off-by: Damir Shaikhutdinov Signed-off-by: Kiran Pawar --- drivers/gpu/drm/virtio/virtgpu_fb.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_fb.c b/drivers/gpu/drm/virtio/virtgpu_fb.c index 15d18fd0c64b..10a66a387bfb 100644 --- a/drivers/gpu/drm/virtio/virtgpu_fb.c +++ b/drivers/gpu/drm/virtio/virtgpu_fb.c @@ -301,11 +301,14 @@ static int virtio_gpu_fbdev_destroy(struct drm_device *dev, drm_fb_helper_unregister_fbi(&vgfbdev->helper); - if (vgfb->obj) - vgfb->obj = NULL; drm_fb_helper_fini(&vgfbdev->helper); drm_framebuffer_cleanup(&vgfb->base); + if (vgfb->obj) { + virtio_gpu_gem_free_object(vgfb->obj); + vgfb->obj = NULL; + } + return 0; } static const struct drm_fb_helper_funcs virtio_gpu_fb_helper_funcs = {