Received: by 10.213.65.68 with SMTP id h4csp476164imn; Fri, 16 Mar 2018 08:55:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELvr76ICIUSNvIEfwDuQYRQ0sY2HyCTjT0m+hWjogqyne5Ls40LKhBVi67e2EbklTzMdL5q5 X-Received: by 10.101.82.70 with SMTP id q6mr1806594pgp.67.1521215741353; Fri, 16 Mar 2018 08:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521215741; cv=none; d=google.com; s=arc-20160816; b=NTFPooUUyONWSo30V8AnSP7WatRYhLkf97IEf0xi38ATn0pXCOJSSxjy0Z08ENvi11 xMf+VJBqIDQ/ULyPDz8QhHqIHoB9mrate+DGrLYakQrFt1ELzp2sbLDuNf+zpVht5zMA PoW1Dj8eZk1wMWSJ5P5XzpOU13zRwMZRtKX9kIMNutGPv7H4Mk+neDn2ajErF1vmkYIR wEhOfpPys+cPiKQYUlUQWPtm0MX8b7D6doU7/A8RM4G2CAeUEIViw2NrPEwZptbL/A4f P/ut5iaJDm2XQnGJ4JWCZj+KCQcFGwmORGrmGsrvZQOGEIojKBHYUf/p9Zoqw1PPIncG uXkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=l8nZbqYQbi5hr68LU9NKswakShexcDSVm7oO7qvH9MU=; b=FFtO4FKYScn0r/eGecK1ugGtbB3yoO8W3s+BXF6r9izNwucLAFHcssGT/Yq9SCntwo dSxR/byrL2tTGcCwemuaFlbte5GjNL/OcGDAwXa+JhEXLXLeuq8dPHe8McDkZ/7TU2PJ l7Ln8Wgdk0gplFTgvrTjCihkywHdk6eWXA6CVZHRpXkE+A9Jl2ZKRoqqAYzmwlw9lBfw +5ejqPgGKg3RTtsYm9gNgRyMH5G02s+tPwaJ3g/klnSoUGk1akxc6A4rKli/PcCaeMB9 gin8z0mRTrmJ0/STZxV7Ybn3aVHqFnmKcFoxa/znLmBP3kqTi5KmcJGjjwZCnhuzusHf y9Ow== 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 t11-v6si6330523plr.411.2018.03.16.08.55.26; Fri, 16 Mar 2018 08:55:41 -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 S934563AbeCPPwu (ORCPT + 99 others); Fri, 16 Mar 2018 11:52:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45906 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965386AbeCPPoR (ORCPT ); Fri, 16 Mar 2018 11:44:17 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AC76BD13; Fri, 16 Mar 2018 15:44:16 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yong Zhao , Felix Kuehling , Oded Gabbay , Sasha Levin Subject: [PATCH 4.15 111/128] drm/amdkfd: Fix memory leaks in kfd topology Date: Fri, 16 Mar 2018 16:24:12 +0100 Message-Id: <20180316152342.059496800@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yong Zhao [ Upstream commit 5108d768408abc80e4e8d99f5b406a73cb04056b ] Kobject created using kobject_create_and_add() can be freed using kobject_put() when there is no referenece any more. However, kobject memory allocated with kzalloc() has to set up a release callback in order to free it when the counter decreases to 0. Otherwise it causes memory leak. Signed-off-by: Yong Zhao Signed-off-by: Felix Kuehling Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c @@ -501,11 +501,17 @@ static ssize_t sysprops_show(struct kobj return ret; } +static void kfd_topology_kobj_release(struct kobject *kobj) +{ + kfree(kobj); +} + static const struct sysfs_ops sysprops_ops = { .show = sysprops_show, }; static struct kobj_type sysprops_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &sysprops_ops, }; @@ -541,6 +547,7 @@ static const struct sysfs_ops iolink_ops }; static struct kobj_type iolink_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &iolink_ops, }; @@ -568,6 +575,7 @@ static const struct sysfs_ops mem_ops = }; static struct kobj_type mem_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &mem_ops, }; @@ -607,6 +615,7 @@ static const struct sysfs_ops cache_ops }; static struct kobj_type cache_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &cache_ops, }; @@ -729,6 +738,7 @@ static const struct sysfs_ops node_ops = }; static struct kobj_type node_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &node_ops, };