Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1D0B22578D for ; Wed, 18 Mar 2026 20:48:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773866898; cv=none; b=dNV/r4p0Hw7UurlhnPAtpZqGCwWl3bzHC6lHZT2SkhD2SA7HreuwD6xRDmnTGDpey0/6HGOJr47+P14fTIXTcUdvtt2OJZnIXPealF0zwqL79Mb0l2053lcZ4jg9/rC9fP8owCEQsySs2i+0Dm7aidWwsUZxK9jWdLk+zy87x+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773866898; c=relaxed/simple; bh=yrdIZaku+ltjPzr5+mmCP5tWE1r2lTt1ZmS6vhPlXM8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rhNcBIH5mgmTM1qc8BbFJKkxlGQY/Udjdv3ecWupxyleDjNd5HkCH09YsCI+aSB1lhyjoex6MbYnLGeeWwhD5RTyw1gJoxQ0lWl3QvW0ZZIVcMcT+zk7gC6rP+aHXhhbNe4jbguuRc3kXRkNEIKOL19rVjaqJEmu8YoTvyiAbo8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kQSvpPLC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kQSvpPLC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6479C19421; Wed, 18 Mar 2026 20:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773866898; bh=yrdIZaku+ltjPzr5+mmCP5tWE1r2lTt1ZmS6vhPlXM8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kQSvpPLCxh51YsXfSO+xjKiI7s7+/079UhRAjpk2cfT1IC/lQQ6vMGKmi4rK+tYaW 2K9bpQ878NLVlfebYNmDKpoHa9uyJDVsLePwS5DIGVBRO8xezfsmHBKWMQpUc9iVK+ zCsQ5JmoR61seIZELZIaXqi5+26FyNk/MQRnYfzmCXG6v4MHLasqE3ndWUIAWQhSZe MppJ96Bn1IeMT9jP1nqHXNpd+FZCS9K3A1v+t+azRoKgIugtSm4XbGawBBZZcouL2n tEIg6oIQozQsIZsmYXVGWR657SuwuC8imZEsQSibJOFaTTo9yOQ3iKlb4B4528jbF+ 3QfrZH5X7huQA== From: Sasha Levin To: stable@vger.kernel.org Cc: Varun Gupta , Shuicheng Lin , Matthew Brost , Tejas Upadhyay , Rodrigo Vivi , Sasha Levin Subject: [PATCH 6.18.y] drm/xe: Fix memory leak in xe_vm_madvise_ioctl Date: Wed, 18 Mar 2026 16:48:15 -0400 Message-ID: <20260318204815.1144821-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031743-pamperer-outfit-94e5@gregkh> References: <2026031743-pamperer-outfit-94e5@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Varun Gupta [ Upstream commit 0cfe9c4838f1147713f6b5c02094cd4dc0c598fa ] When check_bo_args_are_sane() validation fails, jump to the new free_vmas cleanup label to properly free the allocated resources. This ensures proper cleanup in this error path. Fixes: 293032eec4ba ("drm/xe/bo: Update atomic_access attribute on madvise") Cc: stable@vger.kernel.org # v6.18+ Reviewed-by: Shuicheng Lin Signed-off-by: Varun Gupta Reviewed-by: Matthew Brost Link: https://patch.msgid.link/20260223175145.1532801-1-varun.gupta@intel.com Signed-off-by: Tejas Upadhyay (cherry picked from commit 29bd06faf727a4b76663e4be0f7d770e2d2a7965) Signed-off-by: Rodrigo Vivi [ changed old goto target from `madv_fini` to `unlock_vm` ] Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_vm_madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_vm_madvise.c b/drivers/gpu/drm/xe/xe_vm_madvise.c index fe7e1b45f5c0c..9dc801f657129 100644 --- a/drivers/gpu/drm/xe/xe_vm_madvise.c +++ b/drivers/gpu/drm/xe/xe_vm_madvise.c @@ -390,7 +390,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil madvise_range.num_vmas, args->atomic.val)) { err = -EINVAL; - goto unlock_vm; + goto free_vmas; } } @@ -426,6 +426,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil err_fini: if (madvise_range.has_bo_vmas) drm_exec_fini(&exec); +free_vmas: kfree(madvise_range.vmas); madvise_range.vmas = NULL; unlock_vm: -- 2.51.0