Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp713231pxv; Thu, 15 Jul 2021 14:12:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCui7ul5ZSTKJaBF6maLBZzeCS08qqpquS+4W1zLfXnRRiDBJYebpZUfwaj7QMjYDpKznt X-Received: by 2002:aa7:db50:: with SMTP id n16mr9822634edt.298.1626383528845; Thu, 15 Jul 2021 14:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383528; cv=none; d=google.com; s=arc-20160816; b=VNrTowwSd3wekljLDU+t8fohJP2R7eDefZhLoKHBn6NBRmIcXlIc2t11OPzRphOoif GCKVrJeJ+I9Pan7h33S3H6oPp0c3baYN8pmLpn7OyZWNPSHo3VhczImZzoeQnUJtQlsV cYTG66p0TKus2BYp8VK1Cz1etnlMIyW5NEsLeUWgTn5gdMHy9boR4MYwSWtnQrK0oE1T SQPbfrZZUiDcpERvX5BhXfth7mjI6G0g5G8t/CByss3pzk4+pnLKkUVuYAd6fRx/XY2R JPNa8mpuOGYwxnhLUKDSz4a+xrVBpVcjjUtLSztPzSqqI6CFr3GLQl+fVSVu7+GmoMPX XdOw== 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=aX8rlbXCm6r7Rp2CgRBFyXX9EnKyocSpmKr5hcsIyc9MPjvL/wsDUz02Sl5t8mWECu xGe4Zl5+/K+oUcb00DTvTcB8PtFVjS/5uPbyEfpvbGqN5YpDitbijB0lRYv8Wn9WFHhZ mD7CxYGgosPgny64e8vmz1/ATiTh6zLFLKAdBHypmhCgjMyw9xWahkGXNb9n3KDYujln WFH1oYA7BA5LBScSDUHZTFBvYvjKc025yQaHH6R5RK0uOQaC6OE/2QM0vDmune4CARVv U1e7CdFEbzm2qFFQeo16HE1U3fe+yUa6qjb6NRtdK31ZuR1HvxIR3zaKIUjY2xro0x5c yHNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="h5/sZEJ3"; 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 u6si2220371edy.75.2021.07.15.14.11.45; Thu, 15 Jul 2021 14:12:08 -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="h5/sZEJ3"; 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 S242556AbhGOTZr (ORCPT + 99 others); Thu, 15 Jul 2021 15:25:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243173AbhGOTJ2 (ORCPT ); Thu, 15 Jul 2021 15:09:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 963F3613D4; Thu, 15 Jul 2021 19:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375907; bh=0E242/wKL+VMPkZAHRHtRYzna5i8ew0F4mdX8PYmGis=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h5/sZEJ3OZQ4S7gfHW0Vy5zqtjxqv0tOkVaLvAb0pCPl3gmDi8fvupYtRJDR/TA3F DysKd0Obq9+JGvtfw5Y1oAwWmpF4nAgsN/UPHzzAhrLgRS3tTJaTkOicqeLKfYEYRc c4Dbc3n5e8ZeO1Held3c1xk+LO57+w4D8gowSUbQ= 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.13 027/266] drm/virtio: Fix double free on probe failure Date: Thu, 15 Jul 2021 20:36:22 +0200 Message-Id: <20210715182618.859758518@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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