Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3202216pxb; Mon, 9 Nov 2020 05:29:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxi2/oPNEkp6HPemsA6BnA25c9dYvbGBlfQBbXPnXRmz25C7AtR84sqYdLJ7qAd3E+61OZE X-Received: by 2002:a17:906:a106:: with SMTP id t6mr13416778ejy.63.1604928591387; Mon, 09 Nov 2020 05:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928591; cv=none; d=google.com; s=arc-20160816; b=m56Z5lYdMr5cU3ygovFSFi+tqpOw2A0ttoGDjQTqjdvOxemqg7vtIWY0bBXxve6JO4 bzcGSyIGfmRm6/dSoOkq5EwmS4UD/YpEK6LObnbReHXBTTfp8Uf9R2fR/phmUd/k8SWE jLniiixYyAzgckkY2QXwEyO8CBumQ1cSwhFlyeqgWymkkWMeyluirzoOtIvLeTxaseyr 3hKA6Rem/B1hry/WsF+z5/Mwqw7xadDPImVTkFo77fYWsP5xEZqCouA5bvdKC7kXB/OW +oBNKxNh1anjLRT0+rOTQzo145xIiN6z0goTHpH+ArlEYIDVdmRZ2eyxdW9pdYJtpOIy 1PBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tin6ihq9Szc6afOZLbRbzlE5gpCBLo1i3BeCdrb6Ft8=; b=QfOHPIIogjIQKS/7flTcZAoTBRr0yh/uwEqqhMYnYAQS5P0sJfuRlIVWEce9coZxYE /AWJ4YVU3PZjrgOuNvg7QcXtOVJI6+NfFwlu1vcXpcG9BZoFKmo+S9ls7tokN86zFUdf fkS8TJrHj516yAvti22JvN2uRq7MyrKGYAyR4WZXG60nYDMzeZT42WYAR9iWcXlHNlBv mMfFPSiDMp8RRU9ymSsk2j71NHK2ZFFLRBQIR9PO+0/R/fxUH4j5Iyh96Jjgn0kdQUNz VTPLKyVrmM1/05xfTZiSqUzg7/MR2xKLz2C33y3Z4fpxSpEDdeyOQLaArwmp3PziaiSk jfMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wRvUpoqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si6544615ejh.370.2020.11.09.05.29.28; Mon, 09 Nov 2020 05:29:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wRvUpoqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733171AbgKINOg (ORCPT + 99 others); Mon, 9 Nov 2020 08:14:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:40932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733182AbgKINOe (ORCPT ); Mon, 9 Nov 2020 08:14:34 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 630A4208FE; Mon, 9 Nov 2020 13:14:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927674; bh=X4DI0Zq2RbtlaIeDX1Ulp8lHis9rUanRpJQiAoSMBx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRvUpoqL96EKgXxB+nhLg+8d4+F7Hf0tr/f3kt/IsPXXw7rCtbOujSgBQc40ENbno 4vPJr2K4yOnriEJ5M+m+ym/4fmEpsIFqHpJqXvV9o0lo6/zuj3HIt4SRLpWD6+eu0y 3yh0DFs7hmCYApIVJLw1T36e9LFJhApb5yZiL1O8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Karol Herbst , Ben Skeggs , Sasha Levin Subject: [PATCH 5.4 61/85] drm/nouveau/gem: fix "refcount_t: underflow; use-after-free" Date: Mon, 9 Nov 2020 13:55:58 +0100 Message-Id: <20201109125025.496001592@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125022.614792961@linuxfoundation.org> References: <20201109125022.614792961@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Karol Herbst [ Upstream commit 925681454d7b557d404b5d28ef4469fac1b2e105 ] we can't use nouveau_bo_ref here as no ttm object was allocated and nouveau_bo_ref mainly deals with that. Simply deallocate the object. Signed-off-by: Karol Herbst Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 7d39d4949ee77..2dd9fcab464b1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -197,7 +197,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain, * to the caller, instead of a normal nouveau_bo ttm reference. */ ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size); if (ret) { - nouveau_bo_ref(NULL, &nvbo); + drm_gem_object_release(&nvbo->bo.base); + kfree(nvbo); return ret; } -- 2.27.0