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 102E22E339B; Tue, 15 Jul 2025 13:26:10 +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=1752585970; cv=none; b=OWgNhR5D3ELBto7BVhNgS+hlFk+nK/GSdfxHgl2oMKCCouoNgxYDaFJ2qj7dSDaggJJKoWeKNKJz8yPB2r7XNykcy3c9aqSoWK9dSR+Jb6D8BokBEmDKT0GC5Ixdewo0Rir3beh56aC/jZ74GxQOKE53cqm0kYu9A0TBrn7E4XA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752585970; c=relaxed/simple; bh=UMA/9yZhYnpyzgTpQkS8ini2DO+8dlyE0QAb9CRTgsg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tqOU/um+XwRBmMm3rzkxUh452gGiUpovyYXkGppWW1rb6JjVNb4BpCQ8a14f3+twlIU/iAmTI0/E1thVdvcjcEpv9XZcfEcemkLSf4noG+IO8bVEhPF6PqIuHBDT+WpJpq59VJl0UtBPbDh91cgNtwJU37qYg2v2qUxwP7NRK7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iAVzA/HV; 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="iAVzA/HV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98E39C4CEE3; Tue, 15 Jul 2025 13:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752585969; bh=UMA/9yZhYnpyzgTpQkS8ini2DO+8dlyE0QAb9CRTgsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAVzA/HVcxTEXP29r3o8i4YLehgF+vjcd2fUjUrHJu/hCC3/D8TKHj5JdAstQULvt fcF7iHSNDhqNlrigvE4iiEeWjx6kt4pdITR25/nLHL8sMBJiXD+URomwgMMDFjPfya ZsBMsikct4nKJpAw7yfXvCXT1own2Li92cNTid8I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Christian=20K=C3=B6nig?= , Matthew Brost Subject: [PATCH 6.6 045/109] drm/ttm: fix error handling in ttm_buffer_object_transfer Date: Tue, 15 Jul 2025 15:13:01 +0200 Message-ID: <20250715130800.683558095@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130758.864940641@linuxfoundation.org> References: <20250715130758.864940641@linuxfoundation.org> User-Agent: quilt/0.68 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian König commit 97e000acf2e20a86a50a0ec8c2739f0846f37509 upstream. Unlocking the resv object was missing in the error path, additionally to that we should move over the resource only after the fence slot was reserved. Signed-off-by: Christian König Reviewed-by: Matthew Brost Fixes: c8d4c18bfbc4a ("dma-buf/drivers: make reserving a shared slot mandatory v4") Cc: Link: https://lore.kernel.org/r/20250616130726.22863-3-christian.koenig@amd.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/ttm/ttm_bo_util.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -254,6 +254,13 @@ static int ttm_buffer_object_transfer(st ret = dma_resv_trylock(&fbo->base.base._resv); WARN_ON(!ret); + ret = dma_resv_reserve_fences(&fbo->base.base._resv, 1); + if (ret) { + dma_resv_unlock(&fbo->base.base._resv); + kfree(fbo); + return ret; + } + if (fbo->base.resource) { ttm_resource_set_bo(fbo->base.resource, &fbo->base); bo->resource = NULL; @@ -262,12 +269,6 @@ static int ttm_buffer_object_transfer(st fbo->base.bulk_move = NULL; } - ret = dma_resv_reserve_fences(&fbo->base.base._resv, 1); - if (ret) { - kfree(fbo); - return ret; - } - ttm_bo_get(bo); fbo->bo = bo;