Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4101258ybi; Mon, 29 Jul 2019 19:16:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxvzz6twjXWl//Ikp6/Xendc80mnKkY/f9nXVUjxKSdnM8757SS75YjgqOekXLsHrlKpEs4 X-Received: by 2002:a65:4b89:: with SMTP id t9mr37437941pgq.55.1564452987966; Mon, 29 Jul 2019 19:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564452987; cv=none; d=google.com; s=arc-20160816; b=m7DPj3mz6Hdy+0UVvKVPru7bRBJMZcBk9F4kZ+pOLt23fnGohwuyQpHEhk5++++IQp /OxQCCaWRFzr0a0OuxXnJ+y9wLWYf9DD5O8f2pOdalOCwbc09MiXiXmdnFysT8TAfJFi EAScXACziqo1uVg+bdIGRxLB1vhjrWRUgQWCokt69rRxWYX9PzEF4ArABtvESeLS98zu DFgYGU4LBDfpvIrVp3OQ5kdSewngjtNFoKDizG5qQZVppAyBoRZzs1vhwoZi1Ydwz0YU HJUKpfyWlxY3epBjOS7uWcoSWFepZs1C5hUhhels+qN5VCCNeXAk3OLY7vsaJDsiEOGs X9gg== 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=sxlmyTEuB59A/nqd9OyYWKVWmqHjc6TiFHXQRpKh2Jc=; b=ACiQB9Miv18SSng+NN6dgXsvZdfzDztA3REvLrm9sI5gtQcDK3PlwTHjky7HpWVDlg whFUglgvmfadM3N8vowTly1fgflqoDj8Lgm4pUvXJfoF3qhFPU3KsTbpJ+EkTX0fyzui EFM38sp4Q4IJKxwLns29GaBUYPp5UD5w58kigcaOqE9bVc8SKi/DK+c0MJM65HMDIZwe 0CBVnmDtZcwVLLGVagmTt2yeR5C+OuiX0v+wdqISqqLJciGbnIMiSl86CTd4kgfb1Rs+ aDG++veeDYl0ZMfSRHFrp2+e6T8CbznXgeuk4c4LRZuQwkSQ/r0ZOk0C66pyp4dis241 JAWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2KapHvvS; 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 k15si34648679pgj.216.2019.07.29.19.16.13; Mon, 29 Jul 2019 19:16:27 -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=2KapHvvS; 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 S2389014AbfG2Tjc (ORCPT + 99 others); Mon, 29 Jul 2019 15:39:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389007AbfG2Tj2 (ORCPT ); Mon, 29 Jul 2019 15:39:28 -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 C08B12054F; Mon, 29 Jul 2019 19:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429167; bh=ogbnlNUC6S7tpD8mTLT2XLlDbNBJ0HCrvSqhti6Jxuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2KapHvvS6dW9o+4e4HRc8FjdTmOoftIELdt8Cmlw9B9ze7L8fxvhbLvE/V/a+hUgq XFxQ9bNRefFlYiL6DEq4X4ZbW+k4SjgOS4kYb0QHOEOQ40S0qjNty8XeG8bd/fC17X YJecCYP1cmJo15h8ldnEj8X5D1KxkxmxJ0rnWvg0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oak Zeng , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 013/113] drm/amdkfd: Fix a potential memory leak Date: Mon, 29 Jul 2019 21:21:40 +0200 Message-Id: <20190729190658.972829549@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 e73390d181103a19e1111ec2f25559a0570e9fe0 ] Free mqd_mem_obj it GTT buffer allocation for MQD+control stack fails. Signed-off-by: Oak Zeng Reviewed-by: Felix Kuehling Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c index 0cedb37cf513..985bebde5a34 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -75,6 +75,7 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, struct v9_mqd *m; struct kfd_dev *kfd = mm->dev; + *mqd_mem_obj = NULL; /* From V9, for CWSR, the control stack is located on the next page * boundary after the mqd, we will use the gtt allocation function * instead of sub-allocation function. @@ -92,8 +93,10 @@ static int init_mqd(struct mqd_manager *mm, void **mqd, } else retval = kfd_gtt_sa_allocate(mm->dev, sizeof(struct v9_mqd), mqd_mem_obj); - if (retval != 0) + if (retval) { + kfree(*mqd_mem_obj); return -ENOMEM; + } m = (struct v9_mqd *) (*mqd_mem_obj)->cpu_ptr; addr = (*mqd_mem_obj)->gpu_addr; -- 2.20.1