Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp639035pxv; Thu, 15 Jul 2021 12:10:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBcJS1f34bnfqzl1NgMBTrBeSQG5phVbQ4NHYUe4NWO+Hxi2lafDIP3dBwhTp2CrjABIXl X-Received: by 2002:a92:2a0a:: with SMTP id r10mr3708974ile.274.1626376235707; Thu, 15 Jul 2021 12:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376235; cv=none; d=google.com; s=arc-20160816; b=0HDp/jIeT4ydTDk19KmtV3KkpRpsPAQPGqHfbPJSK7Qqh7mZGN1cJ6OUqBfi/Ef3jd cYiXznunRZ/LK3RRhODhJWQcfhSYjxp3Y4MP7WhCiNDHl6nTWoDvExXMTcockGVlZni8 zE59qLLsGdCzF0U+32bNtXdH9hrQnxC4g5eOgrSyajJWvlnVNcKa/k30sta245bmyx1M EaF4vCLhCdoiuN1RP1HAgHLnlKofp6sg+1jNUuQiJ6/6Jnc9VJt5f8pAjNCd13s32a4U VnNhtJwxDGchTDeTu5/zsn0WKtz5lQevH+/LZl7F1M8GiYG6VnldTce5e9jWIO497C/h Levw== 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=MgyqQKqQzLZd9sc2KYIAhuCGuyJ5B2BX9hqrZWp5xtU=; b=TDYa2h0e79P2JNE+45SilttxuUnZqbIungFqOr3Nox4S5luAZysIqSTupMi/RpNZkM muLbMqRMXAIT20YOdhNyFbpIHjYIlbxWciLM2vCk0R3ixlTekLiTrj6O/cZowokeJH17 BYf3HYmdP0kSCzheFQtJVkImEECZcWVOSWrliqxcFRJBxIdAYlv7jW2y6kqWI2iJCgfy n+FLdbRpUmL03JHzKJVBm/RuIka/gYCe1S9v6fOuCgPSuVUYnuaRIxzXh6XMvAK0JwK/ MhwpjpGUAsvkFOxWZKdICQxbn/w1l0zO+83NmfFYQ6k5sHvU3slkmld1xE4298XU4JFI V3YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wLlr/y5A"; 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 z9si7712759ilu.28.2021.07.15.12.10.22; Thu, 15 Jul 2021 12:10:35 -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="wLlr/y5A"; 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 S243608AbhGOTLn (ORCPT + 99 others); Thu, 15 Jul 2021 15:11:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:34632 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242415AbhGOS7l (ORCPT ); Thu, 15 Jul 2021 14:59:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 01780610C7; Thu, 15 Jul 2021 18:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375405; bh=0E242/wKL+VMPkZAHRHtRYzna5i8ew0F4mdX8PYmGis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wLlr/y5AsvIJQqGwdXEJHNq08h+Mcflb9bxwYOWMh1V+a/YIUg/tDeGwzLvRcGNZw w2jhEPw7CmFPeA5Nb/NpYKnAwHxoev9/rLvMYMLj0/Kzf7qzwL8/oNm9QgzSj/vPXZ JSdnzMiXZZ3viPtogzCv1ndRZIQC6tl2NEl8Yk5Q= 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.12 021/242] drm/virtio: Fix double free on probe failure Date: Thu, 15 Jul 2021 20:36:23 +0200 Message-Id: <20210715182555.468049283@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 b375394193be..37a21a88d674 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -234,6 +234,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