Received: by 10.213.65.68 with SMTP id h4csp39724imn; Mon, 19 Mar 2018 18:50:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELs6AfnBqhpwR+jYEOV6+rwPegqaqA5f3V+qyCvSahytvCSsW2RBVOK/0gKlZNjevePl5LJl X-Received: by 10.98.33.154 with SMTP id o26mr12099718pfj.54.1521510659391; Mon, 19 Mar 2018 18:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510659; cv=none; d=google.com; s=arc-20160816; b=Kmn95kqa3EGL4mreVDV9GLmPs4BhUkP2vu6i0IRiSezMROn/WaC8hyeaeJzCc5M6mR NZe2awYOkYt6JEjDd20D169ZNk7pFtHV0q8LPGxbKdzB1IfHJEuErmegwx7N+SESZCls +z1W+DceiIimx5aH364KxhDj/s8Gr/TtY0uWLawIVX/Mt6jpXPPT+/3wzJ5mS/0wdFiP FnT5YHfnIy+L+W8DroGxz0bLBCVr+0WnOn7mWGv9JLri3B8nbv48f8pKAmD8CMzqsiLh R3bQo3nmJTB0tDDYgNmPL33LTFR4ULEwPb8u6TmpukoNrEal/UxnEuRi+o9QL2fG92Rg 90Ow== 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=rwg4X/arFlStzNgsQ7LWLxQ/Dd9J4yN1hl4uzpIN/1A=; b=tA9d1+3xTC0z2TXNS6jn/DySScfQp3ZDPIMx20MjtBDd4eDLtYXYizpySvlPgE5i6K hOCZ3EKlpSupy5Ga3ubkGMr2BIN7ygW1stCN9HziVxTSBOWX78cv5w5a1IbMf1VHqYiX U8zDaLPhPqr1klqilgaLOMqD2JsRiwhulEYd8gcyXiqKXOnkNVsXqeQcSH15Yq/71BbQ hnUd81nB14/eFhoWPapxrZfsXrqRVFriEn5gpdeRJROdrHtQcTGmiZa6Syr2khIvhMEx 5502U5hozX77uoVrLYu7pYOOs4rhnhVJ+itv0BFSEwFaJ3sf0RMKAsrA8XhSeZ54R8CR IRCw== 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 w128si402032pfw.415.2018.03.19.18.50.45; Mon, 19 Mar 2018 18:50:59 -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 S1030921AbeCSUOu (ORCPT + 99 others); Mon, 19 Mar 2018 16:14:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45100 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030666AbeCSSQW (ORCPT ); Mon, 19 Mar 2018 14:16:22 -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 DF5D7FF1; Mon, 19 Mar 2018 18:16:21 +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.4 102/134] drm/amdkfd: Fix memory leaks in kfd topology Date: Mon, 19 Mar 2018 19:06:25 +0100 Message-Id: <20180319171903.960738779@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319171849.024066323@linuxfoundation.org> References: <20180319171849.024066323@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.4-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 @@ -519,11 +519,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, }; @@ -559,6 +565,7 @@ static const struct sysfs_ops iolink_ops }; static struct kobj_type iolink_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &iolink_ops, }; @@ -586,6 +593,7 @@ static const struct sysfs_ops mem_ops = }; static struct kobj_type mem_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &mem_ops, }; @@ -625,6 +633,7 @@ static const struct sysfs_ops cache_ops }; static struct kobj_type cache_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &cache_ops, }; @@ -747,6 +756,7 @@ static const struct sysfs_ops node_ops = }; static struct kobj_type node_type = { + .release = kfd_topology_kobj_release, .sysfs_ops = &node_ops, };