Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2458371pxj; Mon, 17 May 2021 01:53:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9UxcGHc1AevtL/A+0xZT17/CydSKEsIHPpulgD9T7R9J6RJg8IRQGybxXizkCQZ7rjMHx X-Received: by 2002:a17:907:204b:: with SMTP id pg11mr30201459ejb.433.1621241606119; Mon, 17 May 2021 01:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621241606; cv=none; d=google.com; s=arc-20160816; b=R1FbJ/s/68FkprAl76Mi5+hVS85JPYDJvRQnCoT1vDtVWxmzMpMQQNNpehtw2WcdW8 xqB+UF3dhPsff0u6XUBPf/LFzTDRnnyHQ6c5aW1uQ5F+vThEZr16Db4CNHUMeaiXmCTi VtziQfASMwW0xjMdOyKeInJeV2Cx+x+zkj/fIM9uDguctjwwCK0dpOB5yfkYZbZWWPQj cr36ExPdIOm7mcuZ7CEuJq0iYIBmuu7rfuyP/V9dJcDIvsm01o8gm1+F5CldMPRA23S6 LwAUSA4Ezy+SfNUl+7/PTN9A6Rg6DsUrSZZOLlO5R3I9ybscdW4QCJGqfJGoOQwK+XTZ 0n3Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=d+8KyNMS3UthpalbMaLNFWd7rsxivR4hVqKsroFzDcg=; b=qje6jgCAL6R6qXRIR5SOYKeb1ybPpcepHU9BnuR8y8GAOxqb5QltgHthgYSRjEg4gE xhryC1h9VKvZXe2uURzogH2vgjhxEkiFzHTuk+4nvE5uYt5Ph5kOlP67fD8COO+7CI65 hUZKuZTQK707TPg2uf7+KtNZojIyGbrNu1gHVyS268TLdxPQIhvzqeZuzh02MXfqIrWD 6yP0VI1nLV7v4q6eZx/TIvefXJNGdSLCpjBvU9Qdgp5YWUUnzfHwLQ0x2EPF76gIIydg 9AS9R/okgAuMoPWJkXFzAKEAw4YGy+C5i8kZmXyjHtJ7UEmv7jx8v6wEWJQTpM2O44eu 8r3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=I2vVFxhA; 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=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x2si13745233ejs.198.2021.05.17.01.53.02; Mon, 17 May 2021 01:53:26 -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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=I2vVFxhA; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235674AbhEQIvV (ORCPT + 99 others); Mon, 17 May 2021 04:51:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235353AbhEQIvU (ORCPT ); Mon, 17 May 2021 04:51:20 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B932C061573 for ; Mon, 17 May 2021 01:50:04 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d78so3606799pfd.10 for ; Mon, 17 May 2021 01:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d+8KyNMS3UthpalbMaLNFWd7rsxivR4hVqKsroFzDcg=; b=I2vVFxhA/ATWt2N/IbXFrPqogS3dn7PJKuOhKTE9wb6Y27GzC6XH0PNcvDhiFwtqoG YXaTEeoWR57cr1amPtOREU6IqcjKRjX7ILkdjUzKl6zF4VmWPWoAYVMH8cfbOb4/Nrjl pDr+i536viDbi3M1/qgku3ixXyGHzoZmzC+P8PrdtFzOHLFZjoB3jsremhb9gKPBcSoe dU6x2rRw6J0YjRW3O41UoB7NpgnZXP9RjEAgHxAq2gT/0RzOQWxYvfgXTEZuQc8QtHWv EvivxnjN+4Klsi8fZjBzKB6nge9z2xKXCltLdifKAfrEcf7/PRAPbcSEFZrZjGYhXGvn qY5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=d+8KyNMS3UthpalbMaLNFWd7rsxivR4hVqKsroFzDcg=; b=al8KQp+I7G8Cw5Oheip1XT38nUVhHK77xsrW6ZvLe90IvE16xwTe6smz+FV325ewhb 3y4VVstXR6bRQmJXfCHR+lkUfvhEO3onB6mL8FzhhMzJUWDd5lVueYWqULZoK1Q5Bty7 JNgmf76cwYI8372fCETC+MQK3UPSSk9mdayap00JAnkHLbLYcnxWqitFMs6333K5vSGv tfDTEoFUngUNJumCXoeD3rcEt9HaALnBMQJKuz1YP0Q3o646+kNRb7+DdGNsmW9QEZOz UCFXaFQacYAk6hCsgglmLUnh2bqzu6AGa8mJ2d1EWD9LO4Nl/Seq1DhhZxLzDycdcHYG q+3Q== X-Gm-Message-State: AOAM531+V9TlYXLhLv2UEnbASJuK/72knc55ISLkQX9cHjiCajHMZObq Y2y/QE1Syvh8qrIfaiwhcnbI6z2MlPfK X-Received: by 2002:aa7:9ede:0:b029:2d9:ed92:3fad with SMTP id r30-20020aa79ede0000b02902d9ed923fadmr8823581pfq.10.1621241404015; Mon, 17 May 2021 01:50:04 -0700 (PDT) Received: from localhost ([139.177.225.253]) by smtp.gmail.com with ESMTPSA id i2sm14381206pjj.25.2021.05.17.01.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 May 2021 01:50:03 -0700 (PDT) From: Xie Yongji To: airlied@linux.ie, kraxel@redhat.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/virtio: Fixes a potential NULL pointer dereference on probe failure Date: Mon, 17 May 2021 16:49:11 +0800 Message-Id: <20210517084913.403-1-xieyongji@bytedance.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dev->dev_private might not be allocated if virtio_gpu_pci_quirk() or virtio_gpu_init() failed. In this case, we should avoid the cleanup in virtio_gpu_release(). Signed-off-by: Xie Yongji --- drivers/gpu/drm/virtio/virtgpu_kms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index b375394193be..aa532ad31a23 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -264,6 +264,9 @@ void virtio_gpu_release(struct drm_device *dev) { struct virtio_gpu_device *vgdev = dev->dev_private; + if (!vgdev) + return; + virtio_gpu_modeset_fini(vgdev); virtio_gpu_free_vbufs(vgdev); virtio_gpu_cleanup_cap_cache(vgdev); -- 2.11.0