Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3097161ybi; Thu, 18 Jul 2019 20:59:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuZBuZbR6mTDQc8F5nodYXiuVH6TTjVHj4jPh4cofeykLUoQYBMbOV3S57WqE/GSHqKr5t X-Received: by 2002:a63:6c4:: with SMTP id 187mr48569619pgg.401.1563508740380; Thu, 18 Jul 2019 20:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508740; cv=none; d=google.com; s=arc-20160816; b=ikFDlV5agUTUvS/8v0leyxEC1YfBEQHH6GezcMK3Mae0I8mwcSk8NvpAoRsjEwdjNa xld1Zy5t0ORsw+sqz8kqZldM1cvJv015Q7rDegYLutllKAs72V4RHmbUJdksLEApojCR G9PW/8zWR8uSHDtJoxlVNbRBuCiApM1Splqh3kRhKIrpAXtXsgMYWP4+BsYCtV6WWcej 95RgzHyUOUAPUjE/5bD75lxt/FdFF9GSLN/AKIhC/3Ygzn3m6+2TsOk/IpbbhhZXx/Al 5pU98iWLu32nDRwxtficVnlOfMyi9o1LwxDv1XjMSPvQWfO8ftuqzqfo8NJ8QJ1Tk4f5 WaAQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nrskurHZBAoGX3yeOK52r+bqNm1i4lVvCWWPELN0s2c=; b=IS/5zezACF6wf7GoslsWX/WiDK0S3LhqYR4Apl48+0EDmZ07RkxJRMraI/Q1R4g30U uVIfk5B5LvKv88hMIDmDqp0l5PoUAEaTliB4VnZA66E4B/GZ+LkLtPmouna3SvTAKgd3 bbzzUkhJnILqNpY7tun+mRTgboqt4oX7wFQHN1MkmrVPoC9vZISlUEzwAGbVdiw7LHKx BjYep5c20pavxlSE7A2+4aqqU5yFCQr80if9msPOoO7mh2xaat3qVlG4rTgSAoHHlzLS sDX345XPVd7y2nt++k2VaTABh7mLYIjdSOvWLFbxzgDkh5FXXnMTVtkdwyL2LssYxEze NF0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N9COdVf0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si1780968pgr.27.2019.07.18.20.58.45; Thu, 18 Jul 2019 20:59:00 -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=N9COdVf0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727665AbfGSD56 (ORCPT + 99 others); Thu, 18 Jul 2019 23:57:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:57148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727620AbfGSD54 (ORCPT ); Thu, 18 Jul 2019 23:57:56 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2FD92184E; Fri, 19 Jul 2019 03:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508675; bh=teggvQp7PWhRrkJMsK/tso+6YAghi15Fw5s2In74K+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9COdVf0Hd9WaT0PYoM7xHc2/B4FxwrPC6Rwp19SwdXktEmWe5CDE+Ibgvmf+zUmk rK6Cu4b1V+gX7D+rYNU3GOvF+nmBtc10C5ervaXOVRdk/o9U2yMOu1lw0OjNoGBAmv ZfGYNLAj99xH+Iz3IFK9GAkC0cVvBWGPezYekdFY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oak Zeng , Felix Kuehling , Alex Deucher , Sasha Levin , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.2 027/171] drm/amdkfd: Fix a potential memory leak Date: Thu, 18 Jul 2019 23:54:18 -0400 Message-Id: <20190719035643.14300-27-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oak Zeng [ 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