Received: by 10.213.65.68 with SMTP id h4csp1723915imn; Mon, 19 Mar 2018 11:29:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELtOurHPsz9eTFRYhiXLDyhJgt8NndPEIuIHKirU17KubOwwjOzR0uO+yGPz0GlXeL33kr2+ X-Received: by 2002:a17:902:7088:: with SMTP id z8-v6mr13502381plk.174.1521484153318; Mon, 19 Mar 2018 11:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521484153; cv=none; d=google.com; s=arc-20160816; b=c0knY9TOSuggEHdcVJ2RHlGqEtdWaYlyt5RghV2b1r9Y67Tk/ULq64dB9wrp3bfTqL VRrTaQC1R+jrTSX3dffvrvW/Q0ETiPig1CEq/dli0y7R0NrPb6D/RFvsjfP9XjcMFeSR w7bfVY3XUX/8KnLs5CNbps8AwUSXbMxEAco7bhKcH8CpifaaUI8DFI8AkEu6Juch4gpK qzo8wHVfkaS+WzfYXWjw9umuGQ3HsW3y0Xz3tM78q3x6r9G/JuBbH259yaqXEq9Giq5b 1F/Iw6AEWHTzS3NNgtMyFmbCDAPDUuJkg50LU3wi/b3Se7iJfOWxaz+icOgPQjvrY0pj Rn5w== 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=Xe2FemhjG4307yK4iFuPt7kiT/c4Vd25ZLKkBJzvMoo=; b=Iv7JcJx2mPHDXhj0HWRYzsqGots1tylW0NW6O75SqI/7UIHIU3PcCmE+6K18BunXIS q0gGmiWhKNJZTHwIZvhViO+Yg1TtbezcOrPkKTOLymSjTwxdk1GqAHvBPjT5WujT10uz +WWtAhNEICcWRHjjdlxpLJrE+5fZnhHr3LYrHr98bjNPeDPLLxia+oF1Ap+Zk3ZH7TN5 GQBORQ8U9PscONkagEJEmGZD/Y5jz8w11zd8DJAbBB7i/G2Q6BS9cFzdSU8fHqPGlwSM cciWskP7Z+tuaE1R9nzD6mkvlVZgJRQUlmKSCM1K0dujF4CCMgxFbNs9Osvkl4gqSZ5k 0pFw== 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 o12-v6si384257plg.715.2018.03.19.11.28.59; Mon, 19 Mar 2018 11:29:13 -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 S1031679AbeCSS1I (ORCPT + 99 others); Mon, 19 Mar 2018 14:27:08 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51018 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970000AbeCSS0z (ORCPT ); Mon, 19 Mar 2018 14:26:55 -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 8761811D5; Mon, 19 Mar 2018 18:26:54 +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.9 200/241] drm/amdkfd: Fix memory leaks in kfd topology Date: Mon, 19 Mar 2018 19:07:45 +0100 Message-Id: <20180319180759.469174407@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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.9-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, };