Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp626096pxv; Thu, 15 Jul 2021 11:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxpV9z9Ym1qv+m4pjyCUAJUlMPer1KdOgIjONpegq52urf8y4IMezX59Jk9sz5+gtuecS8 X-Received: by 2002:a05:6638:16c4:: with SMTP id g4mr5173084jat.86.1626375178820; Thu, 15 Jul 2021 11:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375178; cv=none; d=google.com; s=arc-20160816; b=F2+mcm2K5HpBWBKGiHYxRK7qOpGpKBHA4LEAZw1BACuaVdzsPEb2/TXSOeiFia7iVZ lRdCqvt4fRHFywXL4xeI/Sy9Ut38x/IDHEHKj+WbVcDU8LJK5tsI5lgOnS1jx0aIn2jL Fa+cVrS5/ndXsifeLKn6+x0FmmyPBIXFHjb+eJSbYXvyOqMjgp2krdyxlz96g5wkRzFr kN9/rrzf24GijZQQ60HLzmABQlPjRKn4dPxBH4GvkBAcNq7N5SkbgtY+xZ1GlFSm/tUz Fj84DAIIUaWool3YjQhZhLuu0tsNSwllbTgm20t7Lmo7DNGU1+qH/PX3ky9m859UgDzJ yaSA== 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=58QhV6zwX2/iwg/PUqqQN5SYeH9cvR4bgC00Dl+30NU=; b=qXVop5aPyldkb09ARVCbq02zqk0xssIoEdRMgKkhlXkh2mTrxr8DAj5axznWbR4P4J KaueEUv7GNqDo3xMEW7C2CXdJbWBWmEHNYyfg0ZbLBKfwqJl7/f/dRcROHhAdcfUoEIV jbriGXDQsVtJpyH3JBUaP+GqFh0wXTm6Q1CeHQMvRO2vmbHfECEFUcDlJ82myupXjv+8 3FEScz/E03TeDv9PoY0PYFZdM1NTc7wRTxqeWItdlmScb/L1pt6xI4aBFkYAdatzAX4K YJ8HZY4dBfrMblXfR/kLd/x4Vp4BGBqtieWAvMOZBFnio9J+GPJS3P/aPuIR/PFa043/ lT7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OHehl+Cl; 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 a16si7023659ilb.149.2021.07.15.11.52.46; Thu, 15 Jul 2021 11:52:58 -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=OHehl+Cl; 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 S241073AbhGOSyE (ORCPT + 99 others); Thu, 15 Jul 2021 14:54:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:53064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240407AbhGOSuV (ORCPT ); Thu, 15 Jul 2021 14:50:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A9E62613E3; Thu, 15 Jul 2021 18:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374838; bh=MStA1xZaRXy8TEn5eqUflyE1JFBIUKgVpsuADnX34BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OHehl+ClkIWl+tcMgGf4bsIs8l+0vV0gQGUCAT6ulL8UPlsYvrfdQHTa1x7mUTvCn L8AdhdiOWZnAxUKlnx+3yjwJy8LoXejyKv38C/EbHIQ+mLou3fqcV2vtxZfeTeFwnb Iw4JSrNNt5uNXOY6P9zHV9hnpmW5m9ZxsT4lrZ/A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xie Yongji , Gerd Hoffmann , Sasha Levin Subject: [PATCH 5.10 020/215] drm/virtio: Fix double free on probe failure Date: Thu, 15 Jul 2021 20:36:32 +0200 Message-Id: <20210715182602.301899366@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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: Xie Yongji [ Upstream commit cec7f1774605a5ef47c134af62afe7c75c30b0ee ] The virtio_gpu_init() will free vgdev and vgdev->vbufs on failure. But such failure will be caught by virtio_gpu_probe() and then virtio_gpu_release() will be called to do some cleanup which will free vgdev and vgdev->vbufs again. So let's set dev->dev_private to NULL to avoid double free. Signed-off-by: Xie Yongji Link: http://patchwork.freedesktop.org/patch/msgid/20210517084913.403-2-xieyongji@bytedance.com Signed-off-by: Gerd Hoffmann Signed-off-by: Sasha Levin --- drivers/gpu/drm/virtio/virtgpu_kms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index eed57a931309..a28b01f92793 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -209,6 +209,7 @@ err_scanouts: err_vbufs: vgdev->vdev->config->del_vqs(vgdev->vdev); err_vqs: + dev->dev_private = NULL; kfree(vgdev); return ret; } -- 2.30.2