Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2746394ybh; Mon, 5 Aug 2019 06:13:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzodNC7ZF/Hmhl5qlFJuktRrIc9Jvyh6yBiMTiaCOsWXQg4laTtM/z1eDKuf+CULRgmV6bA X-Received: by 2002:a17:90a:346c:: with SMTP id o99mr17654835pjb.20.1565010780642; Mon, 05 Aug 2019 06:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565010780; cv=none; d=google.com; s=arc-20160816; b=NsEM7c7Uqk7TL1bUTmpJGCwUK9vv660c42zrFAc4WFCUcehHrMKNAQJTK5N90hmK9s 0cf3oi2bjtAgauhK5MzIxfed5j/LZEUOoaPDrYJtGgKTtSEPpx1INt2MFttP4s428FV4 JQKMqkHAZDO4nWn+vOkXtmaYOb12fmI0vJC8Oo1Ru6JAAmVrXpig2MavZOfzKvhBWcsy LXWbP5048GTcwNPOFp0uxkUS63ZlNzM+0Sn+Q8jrQE+Z5DBzwwLyDkwvQ1eXLmxCLzG0 i9kJ8ojGBLJEmvfhOY+7Tv0JqiI4jvlsk+vc6VWrhb8TYV62o+dC55it4z27D0O8rjjY A82Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yj+lZFqYz47o1CCRiCb5i0kNTeFSM+cMjNV4A3uvHjU=; b=IWbj/gtkRPJbW1a4B4u7BIx1XLjMrYu9+eDc4qSlAtqnP4DT98y6+MrYySs41GZ2sh wWvWAQCd6TyeEX3kSiIanvvWqLAmIQ9YW26NYUOT+Tv1/g1ApLJiLF5T+5YRjQBmTD+T 3awt0pms18kpWD5eGYMvZrVFhbSgNHR0aGOrnQ9i17LR96CWjgZM/ws5x1pES56bEYWD fVqdmQCphq3t8DVSdI7MYSEoHpZcN33z0VkKwxUiO2navDnrKvlKk8d/o/AbMk491BSK SMy2IOGGxDvtkMGLHr00KiQtPGhfzI4HVXJx6fPXtB1m80lbvDDoGA2YPixRXLeGjBjy EA4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2hMCL7bs; 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 124si44513009pgb.11.2019.08.05.06.12.45; Mon, 05 Aug 2019 06:13:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=2hMCL7bs; 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 S1729685AbfHENK1 (ORCPT + 99 others); Mon, 5 Aug 2019 09:10:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:49310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729712AbfHENKY (ORCPT ); Mon, 5 Aug 2019 09:10:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 67F5D2075B; Mon, 5 Aug 2019 13:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010623; bh=gyW6hqBHgxS9UATd8iYnBBFQ6Gx6Cl2pEKQbSIN47Sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2hMCL7bsf0KuPWUEE1Y/ikPfjYnIPPTrYykKYv00NSfUR/tDeQVFqTj2RtwD/0yn1 +kv/U4lAZHi3FcDzoISvRF8GDJgroQvpIANFHO686iskNSAN8sjZcEYkN26xWTRVVh MJC5UnSOlxKv/ECAdgEjrNjC1vQ0L36a0f4Lanco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yongxin Liu , Ben Skeggs , Sasha Levin Subject: [PATCH 4.19 41/74] drm/nouveau: fix memory leak in nouveau_conn_reset() Date: Mon, 5 Aug 2019 15:02:54 +0200 Message-Id: <20190805124939.182347763@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124935.819068648@linuxfoundation.org> References: <20190805124935.819068648@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 09b90e2fe35faeace2488234e2a7728f2ea8ba26 ] 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 Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin --- 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 247f72cc4d10a..fb0094fc55834 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -251,7 +251,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.20.1