From mboxrd@z Thu Jan 1 00:00:00 1970 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 D643E3F9289; Fri, 15 May 2026 16:31:47 +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=1778862707; cv=none; b=oNoqEuCWjDecTOOsLVOdVuzLbCIWuMTrVXatV0uQGvL9I4ZQIOM/W/H38HEfkaSsYmuCN4gL9amGuR5jPdb2wSyTS9fM6gnfxmnCW5TjWn6F6Uhkck6vUa5n+wNVReXVHIvbqvlHG02LIYwKfcLUcEs6wk0gerk69rdbYzpc10o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778862707; c=relaxed/simple; bh=lK6NcF/F35kOTB53XuZI18izab7Gg54G/aRaDsBqFfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i+QdaAKNHQSyYvFLctxq8d38RPLCcw/4Za1Esf22RRXR21rGWIWkkVOzdjVfblz9obDA6UWJHt5Tvhx+J/TpvpVGNdLmFIUpMieFtJeVaO+0eiH26rRF7onV0CvacQKYDMitMMiv7RTtiTyoEpL3P7wZsmpiDSt4RLZClvlUURQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JbevR5LS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JbevR5LS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65BA6C2BCB0; Fri, 15 May 2026 16:31:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778862707; bh=lK6NcF/F35kOTB53XuZI18izab7Gg54G/aRaDsBqFfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JbevR5LSc/fb2q90WO6mPdPqnI3PmRUH5hJalXakTLCiPYiWUO6qFqyC1M6EdIK6c gpT5VRpcu1UA12vBsk9PqeKMyTBH1AIpD+qoksdsHGQdmnmeXC3ldHpBa/zn5FUbaT jLyz6Izst2pTRc0HZM0ogaP8LBCPXgv1CrTp5Jlk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Matthew Brost , Shuicheng Lin , Rodrigo Vivi Subject: [PATCH 7.0 152/201] drm/xe/bo: Fix bo leak on unaligned size validation in xe_bo_init_locked() Date: Fri, 15 May 2026 17:49:30 +0200 Message-ID: <20260515154701.864244022@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260515154658.538039039@linuxfoundation.org> References: <20260515154658.538039039@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuicheng Lin commit 09a8f3c1c11977a6e10c167f26dd298790b31c32 upstream. When type is ttm_bo_type_device and aligned_size != size, the function returns an error without freeing a caller-provided bo, violating the documented contract that bo is freed on failure. Add xe_bo_free(bo) before returning the error. Fixes: 4e03b584143e ("drm/xe/uapi: Reject bo creation of unaligned size") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4.6 Reviewed-by: Matthew Brost Link: https://patch.msgid.link/20260408175255.3402838-2-shuicheng.lin@intel.com Signed-off-by: Shuicheng Lin (cherry picked from commit 601c2aa087b6f21014300a3f107a08ee4dde7bdf) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/xe/xe_bo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -2176,8 +2176,10 @@ struct xe_bo *xe_bo_init_locked(struct x alignment = SZ_4K >> PAGE_SHIFT; } - if (type == ttm_bo_type_device && aligned_size != size) + if (type == ttm_bo_type_device && aligned_size != size) { + xe_bo_free(bo); return ERR_PTR(-EINVAL); + } if (!bo) { bo = xe_bo_alloc();