Received: by 10.213.65.68 with SMTP id h4csp499068imn; Fri, 16 Mar 2018 09:35:32 -0700 (PDT) X-Google-Smtp-Source: AG47ELsdJUCx+DE6Txdp95dUtoD8ujsrZnuGcllQbz3sW3dLBP9PvT7k99lfWej4CfQvM5A1wOx2 X-Received: by 10.98.56.131 with SMTP id f125mr2090770pfa.190.1521218132236; Fri, 16 Mar 2018 09:35:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521218132; cv=none; d=google.com; s=arc-20160816; b=ELalBpik5YQ75VZQdJMTRIXtatFjJ6US5o3cFZ5LMnnqLH43Kp7CJ4JK/34fMV/Adm +vnJTh8WHgKzoSy5a75XHArnf9q8z8J2fGJEH1v7TXWaIqaZttwVCusOEionzz9BqNuF xQpOsRt3DAYyOkj8aujbK1Dtwa2B8Que3Ob5pT6dPug8LP3MpctULeWjTc7Ob8rThud9 8QHvktfnlqVZl67TtNdKJSTO+EDbGFtUwEqtmHYsx+oz0qkVGfPN7dAjnR+P1MCUUFhN Swd0Q1XOUXa2SWX9Al4Lobc/sVchAur1auk60hJUnHQTt4LoKcrmSSmrZgw4d3TpjcIr SoJA== 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=fJaHUCOZ07aa2qEyGZP3vRHmtGBQlxt4mv/wad9QdZQ=; b=sPA2ux9BDAFxzLG9FcvOEOSwHGXHJgmxQbt8Y15ihfHgeo6joCf+b0BZNoHda/kZQN D1CbN1HlJHX/8uq7ZKYECx2D/wtIKdrK3iOzBWHJYtMQ39icYODHgCMH6jZVibqBeKln hQfUaaZQuBXLCXti23HFxns+LcxRK0Xt4kIJp/CfFc/1ZnGL70znqltCcH7DuyCraoAR MjLq2rRE9TbA3I5VLmGPxvniWk10J0YEGrfNXM0/w8cOqaOyfI/uNUwqC/KfmTHAy97w 0FW+owzt8xVrMFDYLpV+lGqIr78nOcPu+3fEio1xkzk9V2NjkDYCnnWPqTSfA73rrl08 6zsw== 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 68-v6si6337712pla.343.2018.03.16.09.35.18; Fri, 16 Mar 2018 09:35:32 -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 S1754485AbeCPPiP (ORCPT + 99 others); Fri, 16 Mar 2018 11:38:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42136 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934483AbeCPPiE (ORCPT ); Fri, 16 Mar 2018 11:38:04 -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 1ADCE126B; Fri, 16 Mar 2018 15:38:02 +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.14 092/109] drm/amdkfd: Fix memory leaks in kfd topology Date: Fri, 16 Mar 2018 16:24:01 +0100 Message-Id: <20180316152334.916800946@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152329.844663293@linuxfoundation.org> References: <20180316152329.844663293@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.14-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, };