Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3198495pxb; Mon, 9 Nov 2020 05:24:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ9vCf8UoPJDTzTu+RO+V4zQcB2yEFkizq4sh/lXiFQkRzDuEHVlRtyAXWEPIANLuBMpQv X-Received: by 2002:aa7:d54f:: with SMTP id u15mr15418408edr.239.1604928258120; Mon, 09 Nov 2020 05:24:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928258; cv=none; d=google.com; s=arc-20160816; b=Mea2NbX0ge/mE3kyCVd+aWKjH7/1uAwbBW5xkKRc6LFAaLKxW/ar97pzTpWOlZKRFV 6fZN+wIX0P0I/L+mQYnUajGpw0RoenEwwPR0M2w/3g6H0YGb4WZeplkQ707c0Q9EZiDv qvWm0zGnFvjdzxW+1ue/HngRt7wzb8psBGUXbzLtBs16Ul/BCZmzhJLwDfuq9Qins4/o GLHyvOxkrscM0RHhlyu3+S0Va0qusTL1378rCVlB+oZ5b4OGmJBe5H+HaHijxVgaaDxD l996zjwGJFp2+voR2x0eX0Jk1iGofpmD8Pl4/wsQMC4IrwB6rw1xhOHZXduff/vmymzJ wfqQ== 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=+OSI2u80ObqPMCV2RSu5sQcZy5na27Tepc0BMSPdIL0=; b=RqCPpsVWX5jpJClr3osXtIlv5XV9PunpHHVHzb77Q1QPWYh1FH0ERarrK071Oiff7h rO/+bi5IiwHV/+3DhvVdQutsZE1F/tt1a7D7KH49HMKsSVSAqzb/mCIZccVE3bvU8/52 tjV5U3/a9EImommGT88+woZH0lq0szwAk5yqBRgG8S0JwOSyG3KYwAJFXhjcSdAtKsRL Wjf4YtfDj4CH6Al9Hk9PtAvLAk3mq3qlupyrSACYcwDXMyzIDItquuAFnNrP5c5pLvjk xhQh9cbvvmQ5xKbpzQaYPZJWkF09JxU5hqHjaLqNEJofwg/XfaKhWZwH6JLHmawXvb0p uxcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sNLun7Ab; 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 j14si6977877ejx.329.2020.11.09.05.23.55; Mon, 09 Nov 2020 05:24:18 -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=sNLun7Ab; 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 S2388167AbgKINWH (ORCPT + 99 others); Mon, 9 Nov 2020 08:22:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:49968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388151AbgKINV7 (ORCPT ); Mon, 9 Nov 2020 08:21:59 -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 14C122065D; Mon, 9 Nov 2020 13:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604928118; bh=6HcL1lHO4SRSWhdjXDo4w7v3qXL87HTS85ZgCKdrzmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sNLun7AbASznzTLrumogYUatta0yzJGIRU/T0wLlD+avs9IvehDBqeI2bnwK69iH+ mvZS5KG3f4uA0YQygsBwaYOq435W+2kjYtdpHMCoGNItXjfBdIePQyjGC6k+F3KDWj kCI0AD83rducZAQVtcT8oxccbrOIlpbVI25z0g6c= 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.9 103/133] drm/nouveau/gem: fix "refcount_t: underflow; use-after-free" Date: Mon, 9 Nov 2020 13:56:05 +0100 Message-Id: <20201109125035.642758567@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@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 81f111ad3f4fd..124d3dcc5c590 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -198,7 +198,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