Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3797027ybi; Mon, 29 Jul 2019 12:48:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2UP4GW5349jFM3hRoOJ+wQSnyh1XJs7B+Ex/Q++iWNfo/w/GA2NDYmckgByWEpwL3XZet X-Received: by 2002:a17:902:1a6:: with SMTP id b35mr15592683plb.190.1564429738233; Mon, 29 Jul 2019 12:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429738; cv=none; d=google.com; s=arc-20160816; b=Q7yJpKESSDi2DtbjUw+7LmQLe3lLo6qsA3Ag/z9sZGV4E++kGqipwWrU0yjVW4yaAt oEc/Q5Nrbg5wYQPnxv0plcMvOGRr8Wkr2sU1iJTnTh1xYSi3SidqkqZtyRSpwdN9bOYT ++0xrYQEPA3+1HtCvYjIz6S05FQZ2BvOyvZ5fE0OtLTPDqujQSUL4NT2BTF4z2Dz4uGy sC3yf7Phinas2kwluU4FeHrXSzcwganclJuwpDFUIN5NJaFCoJZ7GFXau19uFeXv5zhl RJhezNE1QXdYvEWlmTTzHRAE5664DQlXv3GK8LKGc2HOCbIG+dN3ZiYdqaiOxy2k+2yw wMUg== 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=8dqlUCcJ1OWf/G16PLEMHaQLkGM6r2eM799DKQv6/Jk=; b=iwK4mW7Lir7rxyQYQjaQgtRTJ0BQxy8OzSwB+EZn8uvmKMiD/Izj6eaUhvFUvEBbRI KL+S9D7BAwX+vAWtHOuf4TrmyUFY6Biuu2iO3rk7uQfgUJDMlXSEu+PNsJX6ffAbgxUw UnrBPvQbihH7D0iG0dvghNLdZa2i2VgF6+dca9o8LrhiHQXIii2nZ5dVc9hjQKq7DTuA wtMmKNkYdbcGEqTq+BC/BipUDJMFJze3VJH1E/ensN0Ic1ZCu9dFIwZw47tcSt4ZJ7Ep uiUQwzg32/kYopBV1NsMvm5LkkrOqUz5KwRmTnayH/sW914+qLhPcVHTW0naxQs0OAZF hOFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pJxxOfyT; 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 m63si28329264pjb.8.2019.07.29.12.48.43; Mon, 29 Jul 2019 12:48:58 -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=pJxxOfyT; 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 S2390130AbfG2TqZ (ORCPT + 99 others); Mon, 29 Jul 2019 15:46:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:35618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390125AbfG2TqW (ORCPT ); Mon, 29 Jul 2019 15:46:22 -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 5B6A320C01; Mon, 29 Jul 2019 19:46:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429581; bh=Y07Jhuh86TB1zC+Il3gXb0CrcePi+HPbIZrlTPtBLKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJxxOfyT4WnvDZqHafwrs9iBLZ0kOOQAwMw/X40YGgjYROf6cq8++nXOEYN/U5snp 2HgYyBXlv4zM8/qg3rgaeTt2JVjSbMMVF18uQzbWWLxC4z0qQB84WVnPGaWbTv5i2+ t7IGJJ79Zpp5uhxpHtavbi/HtNSnM8jkmKpmsiNY= 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 5.2 029/215] drm/amdkfd: Fix a potential memory leak Date: Mon, 29 Jul 2019 21:20:25 +0200 Message-Id: <20190729190745.138948656@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 9dbba609450e..8fe74b821b32 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -76,6 +76,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. @@ -93,8 +94,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