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 4893417BEC0; Thu, 15 Aug 2024 14:36:51 +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=1723732611; cv=none; b=hrlWidfCKiGujDFNreY+VX37e4fDI4SAJtLdisLDua/iu1Gx3FUqVw3/73HeBWGdClQM/lD5IG/gJ2icrgP7rBJaXmUGIbqBTG2aX39R0HYF1LXNkyqGoqykAxtk3asEMe34+FHsyFflyWhtHatpjJKuGweqxNi728SDGADcxAg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723732611; c=relaxed/simple; bh=D4OK5lfSo+QMAaRd5VJDUl9KtM+GO9fwrgccBX6JV4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=C+Sdm8ecCx6WI+2trtwz+rUS5KC5KsS3tp/X6aWLATxpwW1RU3kA65XQvlOrjeSovvXN0FgBtvclZ24bH+pzTKQxhvcc1xj9UgO42lHHKdl+/IR+7Z9Oy0T3ZetuL61EeTaGch8LhvHAnRnOoXaBP+B8q0HlGnEhAodMSepXxM0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Hh1+eX3A; 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="Hh1+eX3A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B44C6C4AF0D; Thu, 15 Aug 2024 14:36:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723732611; bh=D4OK5lfSo+QMAaRd5VJDUl9KtM+GO9fwrgccBX6JV4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hh1+eX3AtBm/ALVIOvhgLyvbA4cbCEt4M+PdtrWQGHGD/Uccx4tZFrUXTGBzOgY2r ZsxPkuOFErH9qvyC3K029fVbE70MVkF5PdwX2S9dUtODg55Ydkd0njbflIbBGpgGP3 KNETl2Spg4gcWyzQ/JeEwwmp5/sleU5sb/9oqjcU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ben Skeggs , =?UTF-8?q?Christian=20K=C3=B6nig?= , Danilo Krummrich , Sasha Levin Subject: [PATCH 5.10 233/352] drm/nouveau: prime: fix refcount underflow Date: Thu, 15 Aug 2024 15:24:59 +0200 Message-ID: <20240815131928.442365707@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131919.196120297@linuxfoundation.org> References: <20240815131919.196120297@linuxfoundation.org> User-Agent: quilt/0.67 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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Danilo Krummrich [ Upstream commit a9bf3efc33f1fbf88787a277f7349459283c9b95 ] Calling nouveau_bo_ref() on a nouveau_bo without initializing it (and hence the backing ttm_bo) leads to a refcount underflow. Instead of calling nouveau_bo_ref() in the unwind path of drm_gem_object_init(), clean things up manually. Fixes: ab9ccb96a6e6 ("drm/nouveau: use prime helpers") Reviewed-by: Ben Skeggs Reviewed-by: Christian König Signed-off-by: Danilo Krummrich Link: https://patchwork.freedesktop.org/patch/msgid/20240718165959.3983-2-dakr@kernel.org (cherry picked from commit 1b93f3e89d03cfc576636e195466a0d728ad8de5) Signed-off-by: Danilo Krummrich Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_prime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c index f08bda533bd94..65874a48dc807 100644 --- a/drivers/gpu/drm/nouveau/nouveau_prime.c +++ b/drivers/gpu/drm/nouveau/nouveau_prime.c @@ -81,7 +81,8 @@ struct drm_gem_object *nouveau_gem_prime_import_sg_table(struct drm_device *dev, * to the caller, instead of a normal nouveau_bo ttm reference. */ ret = drm_gem_object_init(dev, &nvbo->bo.base, size); if (ret) { - nouveau_bo_ref(NULL, &nvbo); + drm_gem_object_release(&nvbo->bo.base); + kfree(nvbo); obj = ERR_PTR(-ENOMEM); goto unlock; } -- 2.43.0