Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2389032lqp; Sun, 24 Mar 2024 17:15:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/97EQ1vM9Tkg41TWbDSB7+8ndlOlxQrK5HLPdXais4Q0ubl9+iRqClL+awRjRksYJXoCOSPVXrxlzZWEVTTQumIPyop5m9zVoiN/DDA== X-Google-Smtp-Source: AGHT+IFXj6oO4ro5uwhqwhVXMOQVw3FvRc9weKToB+ci6OOn2psqaBsOjVOFT4Mdrh/os1mSxuXI X-Received: by 2002:a05:6214:1242:b0:696:47ea:df2e with SMTP id r2-20020a056214124200b0069647eadf2emr4589979qvv.23.1711325728670; Sun, 24 Mar 2024 17:15:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325728; cv=pass; d=google.com; s=arc-20160816; b=CY9K5g7th6NazwjOJT0giX6WVbLsZ2D6/EfHURQ+j1VczE/+IwR2qu+rFoxrrCLRc5 yoHWc8kJp9Cm8J9Yx+HOVXgFMOCfS1K+19ibzC2v4m7hhcJuDw/44/S/ZjgYcT53jtqk fs/gsFsPgpdjj7mGM/3Y8YzyqIuarB6eAEArl2w83YFYLDTzyopSYTiTWfqa9RXbCm6T keOmDs1HNOpTI39EmVRaWRTbnFG/PdwLXIOvY6M1Zin1pEMgDS4eTS+/Akw9qg7yAABl OOKF4SxMS7mfUeTDYzfHzR81JbzlKsVPZUzpPN+g7hcJYdcRVWf+tLceI7hH3iKheT/Z /Dng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RjxzLHVAZixHGXBobfCvwfO0g9B0Kno/D9G0hYj7lts=; fh=u/HVzQgnC5PVDSFetM17/BSggWTrf6KFskyyOTKRslU=; b=IIzPv+14mLi3km4UrvRv2jw281dSwRBs8JU5vd4y4ZR6hzd45x7e+XUOzSGuLrNCq5 7VKsEdI7rIFD8oEsrik5hu6BdNggI5sUkwaflk03GBpziH2hNGoDeCNg9+qDAY1Cu667 CbdNY9vRfa5/deDQ5tIv08YJ56eBlPmsTrzkhqv/WifRvQEZyCHZbYSmrzNo7uaKwMTD DwJZuL8yME+cuQ3lvfj9WaQg92l4mTQX4eIzGuzhuCR9BwJEzaTI6+bGbGBI+c7jO3Ti e8BVYwENmUuijsgNhrHZoIizoc1GHM73Wq7Fc2Rdc0BpBYCzf+v+k1GneAx4P+0nzJrg 6Cug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b1Hd5Cyl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113349-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113349-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d6-20020a05621421c600b0069691f66086si264593qvh.113.2024.03.24.17.15.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113349-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b1Hd5Cyl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113349-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113349-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 67CF21C22B46 for ; Mon, 25 Mar 2024 00:15:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1564199E9B; Sun, 24 Mar 2024 22:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=kernel.org header.i=@kernel.org header.b="b1Hd5Cyl" 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 EFAB5198B75; Sun, 24 Mar 2024 22:42:29 +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=1711320150; cv=none; b=NjAT0M13iTautpzJanwgl+JUt44uC1d/YKiFL1GcCEKaLL/sqXcFEsq+jTy69nQFkYer461sXh+6Pk2I8iMPw2JcFd2FhOVnUUytT0l3060Zv+290PsFo+VLcvM4KlROHTKLBWxc9Cvqm3l/g4inEnQoQUjrc2KUZIJPWf5FE3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320150; c=relaxed/simple; bh=1csZ9x4MyVNb8NfT0+Ah6w2V60OsIm+IajesknxVD8Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kr1HpMhteQxF7wYee487pMwdmVPs6nV+hrtYa/knL8P9+B0MCd0ZMZCa+n7o78Uu/D8uc1QyDCzghTvTGPK4Ui3J4+LTvr/CRVDt4oHz3axh6f/wZulZ53K4RQpFysPgo09W/KS0IfdIZ3orWpqe5W1PIfP8JnGJV02JLU5lEQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b1Hd5Cyl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 335C0C43394; Sun, 24 Mar 2024 22:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320149; bh=1csZ9x4MyVNb8NfT0+Ah6w2V60OsIm+IajesknxVD8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1Hd5CylH6jdeTwtHIEibNMBoljLlZGVHzuZVqqsfOEb3fLF2CWxoOupfvsmyqYI3 gk/hatObXj+9Vl2BJv+D/nSC2xkeIkrBfGoVrqEBh7T9eZgBzPdNgnisWVxlo9ZOIu c0vkm3GydZEEJ3j5cF6g33ieZE85E157bhb71l23ghfC/JeB2r2fgOtrfzoD1nrylF vboJkOkfiB0a9gnYXCtmGmzkVBUhyCQ/ZT0HbQ6e70zlesXuuHbejV7nI5OZi1aKcb e76GhkGVSmDWvXcp/DvXoSuxO+kDf6bfMcEOasW7wvUc4+oqi8VyLqzyI5Yjtypp/J 6uMoCDSjuJP2w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Fedor Pchelkin , Thierry Reding , Sasha Levin Subject: [PATCH 6.8 458/715] drm/tegra: put drm_gem_object ref on error in tegra_fb_create Date: Sun, 24 Mar 2024 18:30:37 -0400 Message-ID: <20240324223455.1342824-459-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Fedor Pchelkin [ Upstream commit 32e5a120a5105bce01561978ee55aee8e40ac0dc ] Inside tegra_fb_create(), drm_gem_object_lookup() increments ref count of the found object. But if the following size check fails then the last found object's ref count should be put there as the unreferencing loop can't detect this situation. Found by Linux Verification Center (linuxtesting.org). Fixes: de2ba664c30f ("gpu: host1x: drm: Add memory manager and fb") Signed-off-by: Fedor Pchelkin Signed-off-by: Thierry Reding Link: https://patchwork.freedesktop.org/patch/msgid/20231215093356.12067-1-pchelkin@ispras.ru Signed-off-by: Sasha Levin --- drivers/gpu/drm/tegra/fb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c index a719af1dc9a57..46170753699dc 100644 --- a/drivers/gpu/drm/tegra/fb.c +++ b/drivers/gpu/drm/tegra/fb.c @@ -159,6 +159,7 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, if (gem->size < size) { err = -EINVAL; + drm_gem_object_put(gem); goto unreference; } -- 2.43.0