Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1612175ybi; Sun, 30 Jun 2019 20:14:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg437pYv991aSUUlXXoWjafz/5cdCbMPf0XA887qZcsnywVazFwIVGuNmvNMRcscsg6Aob X-Received: by 2002:a17:90a:bd93:: with SMTP id z19mr28624160pjr.49.1561950888252; Sun, 30 Jun 2019 20:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561950888; cv=none; d=google.com; s=arc-20160816; b=kJH4vxunnQginEatoiJaKxlT7gInQRAZ1X5pVeD560BZqnUdG1cOmbL8yzDnUkrvTB 3xcnvl2nK+K+5YHSQhq6Wbh8Gdpq2axj9ox50GfGGKilU30RnnXMssf1MLWudwIvFOmq 1lR3VEBNK0zcRuXoIih2x34UWC/ErkOw6adwTLt4hOyBcqoZtEH+cl1TWNNH+ZefJGLI 3VuQu4Q/22OAtXzLfut5yMQ/mOjgrZnmGPfOjko8ajAAFcA8DTzAWFMK5oQx4PHjseUA fv2lbc4L1LWLaHAyoxQhUsBfIji2iKWWQm/NFAZ4nn/1obBJLqMMw5heoegsCt+/u6WW pn9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=3nlfCK2LLIZoxkQrQlzL3Sgl7levhfGKyTKX6HzEtoU=; b=owqvkx1YFSPvnGV1K1kzpc58SqhD9rZAtn5NyaVJlL4SP6wF1MZb0S8n35koYC8LLT +jDVwGQiBXHtYEyk/GDJ7e+6HVQkhLgYXvDoRJFoOBRbP64KpeHAVj30w7JU4M1y25xc aNmoZV8btwcaIi6npUoaiweqRjq/j839+vZSnrgXJ0j85YW2MAmycY/JmLMTbZwiGupf YsNmFd9C3mCkfG1D3gUmQlGzEmFlWuZSBHqrV2kz6htJuWHYTEkx2exs/SH7tqglpjAC wlXvm8tARyza6vtqDTHUXbuYxVeqJELPKV+uc1H+pDUI7THwPpzwtBYCMUVfAgO+Io1y iOYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si9276444pjv.99.2019.06.30.20.14.32; Sun, 30 Jun 2019 20:14:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727316AbfGABs5 (ORCPT + 99 others); Sun, 30 Jun 2019 21:48:57 -0400 Received: from mail5.windriver.com ([192.103.53.11]:48764 "EHLO mail5.wrs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfGABs5 (ORCPT ); Sun, 30 Jun 2019 21:48:57 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail5.wrs.com (8.15.2/8.15.2) with ESMTPS id x611lk0l020239 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Sun, 30 Jun 2019 18:48:01 -0700 Received: from pek-lpggp6.wrs.com (128.224.153.40) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.439.0; Sun, 30 Jun 2019 18:47:47 -0700 From: Yongxin Liu To: , CC: , Subject: [PATCH] drm/nouveau: fix memory leak in nouveau_conn_reset() Date: Mon, 1 Jul 2019 09:46:22 +0800 Message-ID: <20190701014622.13199-1-yongxin.liu@windriver.com> X-Mailer: git-send-email 2.14.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In nouveau_conn_reset(), if connector->state is true, __drm_atomic_helper_connector_destroy_state() will be called, but the memory pointed by asyc isn't freed. Memory leak happens in the following function __drm_atomic_helper_connector_reset(), where newly allocated asyc->state will be assigned to connector->state. So using nouveau_conn_atomic_destroy_state() instead of __drm_atomic_helper_connector_destroy_state to free the "old" asyc. Here the is the log showing memory leak. unreferenced object 0xffff8c5480483c80 (size 192): comm "kworker/0:2", pid 188, jiffies 4294695279 (age 53.179s) hex dump (first 32 bytes): 00 f0 ba 7b 54 8c ff ff 00 00 00 00 00 00 00 00 ...{T........... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000005005c0d0>] kmem_cache_alloc_trace+0x195/0x2c0 [<00000000a122baed>] nouveau_conn_reset+0x25/0xc0 [nouveau] [<000000004fd189a2>] nouveau_connector_create+0x3a7/0x610 [nouveau] [<00000000c73343a8>] nv50_display_create+0x343/0x980 [nouveau] [<000000002e2b03c3>] nouveau_display_create+0x51f/0x660 [nouveau] [<00000000c924699b>] nouveau_drm_device_init+0x182/0x7f0 [nouveau] [<00000000cc029436>] nouveau_drm_probe+0x20c/0x2c0 [nouveau] [<000000007e961c3e>] local_pci_probe+0x47/0xa0 [<00000000da14d569>] work_for_cpu_fn+0x1a/0x30 [<0000000028da4805>] process_one_work+0x27c/0x660 [<000000001d415b04>] worker_thread+0x22b/0x3f0 [<0000000003b69f1f>] kthread+0x12f/0x150 [<00000000c94c29b7>] ret_from_fork+0x3a/0x50 Signed-off-by: Yongxin Liu --- drivers/gpu/drm/nouveau/nouveau_connector.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 4116ee62adaf..f69ff22beee0 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -252,7 +252,7 @@ nouveau_conn_reset(struct drm_connector *connector) return; if (connector->state) - __drm_atomic_helper_connector_destroy_state(connector->state); + nouveau_conn_atomic_destroy_state(connector, connector->state); __drm_atomic_helper_connector_reset(connector, &asyc->state); asyc->dither.mode = DITHERING_MODE_AUTO; asyc->dither.depth = DITHERING_DEPTH_AUTO; -- 2.14.4