Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp220105pxj; Tue, 18 May 2021 01:39:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym3KNDeC+Ba6+KbS+GNxrWDQ9mRg+7F4y1Fkm776p1iharZuWXm1ZrdDUcTTl3UPB2WXVj X-Received: by 2002:a02:cc37:: with SMTP id o23mr4271276jap.35.1621327189402; Tue, 18 May 2021 01:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621327189; cv=none; d=google.com; s=arc-20160816; b=GNWNr3/fddsyeCoXRKcsTOyNOBW3d/gFKfUzqK6AcQMo8eJMJT1ilxor2v0epZvK4O +y+mAAwhTeKa1Ef2oXh5Y4EwnH5YUZ4Wg7XHx5PcV8UZLBKSeBkSQVxak3afV3qmtoI/ W1GHBs6vfe/ZFg7Mv9m+gmMPHQ9fyt9oSAZyLrBAV19sdYS/JXJKmIiDVe4TEJ0XhsmQ QxFM6enoeWhFGi/6JpKzLmG6mwtIlvj11ojoO5V1buAojH/uogL+GPQOlMkdmjOHLynr UmplQxJL+3j1X0BqPqi0PCc+zDpStsTuJjUFLPKVzsNCef/+LWawssO5ZRPXD/XBA+Ur INdg== 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=lvgmLtloJA4aFTv9JUYQEx6A2a6fJ0K7DVX5KTRr5Xc=; b=qQc/fql8F8MRetiTxMYZhQ9UxtgsPhqeDIIaKhMNjPG5VLvXObYigBfgThMYMejfG/ uIZkVJNfYhIS7GO4FscyVi5wmlv/kn8/aRP4oKSh9eRVclXK9KOFToFBuu/ZPr5NCjeS bwrf+lYygcvTjwBGoDCZsbNy0TlKKuAVUtQZAvUm21ywsg/l8UijaJYbyWyPj7TcaFse 1XkPCaKbVBv3v/oKyGxyK8C18/R6jahoVySKBr582NF2eXEe/ruHzyHk0mLKBT2beelw /+BmDcrP9zsR2btkchee4pJ6r7ui9XuzYWUOi+Hkdr5oqWQNVG857vh93X5ORw8zt6MH yVmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YHywzTxw; 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=pass (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 h5si24640768iol.44.2021.05.18.01.39.36; Tue, 18 May 2021 01:39:49 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=YHywzTxw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242085AbhEQPBv (ORCPT + 99 others); Mon, 17 May 2021 11:01:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241502AbhEQOv4 (ORCPT ); Mon, 17 May 2021 10:51:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2720A613D9; Mon, 17 May 2021 14:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261412; bh=T5HBUSrZ6/zYpnEUGgF+yo9YlFrserrzIbd8ccwjIKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHywzTxwSggirSCzX0CRD3iTc+7wGxPYI+tdDTovMXRGFAtbkDZ0l/+Sxci9CVHsK CTZ9ZYSV8u8JFGqSQYkc6HfDMAKINtUE0Lg4dCAkqDSwcrnag0wP9XgKhMqFs+otz8 zADs4meCkga7RTPlDEuGZZoUXmW5gSfvO1ixZnww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Matthew Auld , Jani Nikula Subject: [PATCH 5.12 343/363] drm/i915/gt: Fix a double free in gen8_preallocate_top_level_pdp Date: Mon, 17 May 2021 16:03:29 +0200 Message-Id: <20210517140314.200993433@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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: Lv Yunlong commit ea995218dddba171fecd05496c69617c5ef3c5b8 upstream. Our code analyzer reported a double free bug. In gen8_preallocate_top_level_pdp, pde and pde->pt.base are allocated via alloc_pd(vm) with one reference. If pin_pt_dma() failed, pde->pt.base is freed by i915_gem_object_put() with a reference dropped. Then free_pd calls free_px() defined in intel_ppgtt.c, which calls i915_gem_object_put() to put pde->pt.base again. As pde->pt.base is protected by refcount, so the second put will not free pde->pt.base actually. But, maybe it is better to remove the first put? Fixes: 82adf901138cc ("drm/i915/gt: Shrink i915_page_directory's slab bucket") Signed-off-by: Lv Yunlong Reviewed-by: Matthew Auld Signed-off-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20210426124340.4238-1-lyl2019@mail.ustc.edu.cn (cherry picked from commit ac69496fe65cca0611d5917b7d232730ff605bc7) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gt/gen8_ppgtt.c | 1 - 1 file changed, 1 deletion(-) --- a/drivers/gpu/drm/i915/gt/gen8_ppgtt.c +++ b/drivers/gpu/drm/i915/gt/gen8_ppgtt.c @@ -630,7 +630,6 @@ static int gen8_preallocate_top_level_pd err = pin_pt_dma(vm, pde->pt.base); if (err) { - i915_gem_object_put(pde->pt.base); free_pd(vm, pde); return err; }