Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3143329ybi; Mon, 29 Jul 2019 01:39:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVSCi2i6gYycblBrwcYmhra4gm2gtnpKLVqxs+vbUV225Yeu7qe/8mf4iPvghdx9KPKmmS X-Received: by 2002:a65:57ca:: with SMTP id q10mr106253740pgr.52.1564389541590; Mon, 29 Jul 2019 01:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564389541; cv=none; d=google.com; s=arc-20160816; b=oYWZgaqZz3cSW9qqO6Dxb9B/TVY06rz2JfY3h4nvuRiDHZ266GOD541SctPzww0Vhk LBGBPIeNpcJpsJIOFUG6cBg0oUP8Sp5/5iJ+y+mx1QY/Eor4hAIbZpLv1XLJ/nynA4L7 EovbXOxe9JXLk+ngTnZw5pIjenAV0xTtbfZ4VmMoAEUrOOc9toaBSsGY4EdmeJgXGNih PVQk5yxXJtiBSHy/F+xMTHdBVZImL25nDA/cE6NqAyoddvls9Vhqq/EjFIa/jem+4hKn foacIFh/1Z04XPmzpTpv5agxnxRU7gs6fE3dSdRXcFSCtqX+e4ed9N4rr75Q4gLp3Z0+ EZ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=hx3TEgY39elQOvRZKIYlQACZaQ3s3d5tMJmYsbA0qFg=; b=vI18ZrHtfJz1bKpKMQD7r2DQw1NWQqrWf4FgDdw9jxfhfFQP5IPggFwe48uN7KY0S+ Qa5oVt1B4ufKgVGRpaI7nvuC9fQ41PrapmV7lhTP2DRaeaqxcNwjRX+EXpo9s81PE3Db 8AhZwBb2xKl+f9TS2QMZzRUuiCS3NvgUOowoQywd7AO78HA4zGSoAcepbotbfVs+JlQP 80W4+aaYBaFCzte5R+vid6e661B2cW+xLceqykmzdSWzVqJ912GD90W4RV4QRJv9Ee4D 6QtPeAiuA2UE9nf+My6bOXSGo6Ruep1m9Bp79eH2GPE+MNCKqd/GHZB89bNUR7guEAOH AT9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="iST9y/tl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k73si24067440pge.353.2019.07.29.01.38.46; Mon, 29 Jul 2019 01:39:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="iST9y/tl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbfG2Igy (ORCPT + 99 others); Mon, 29 Jul 2019 04:36:54 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45386 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfG2Igy (ORCPT ); Mon, 29 Jul 2019 04:36:54 -0400 Received: by mail-pl1-f196.google.com with SMTP id y8so27241387plr.12 for ; Mon, 29 Jul 2019 01:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hx3TEgY39elQOvRZKIYlQACZaQ3s3d5tMJmYsbA0qFg=; b=iST9y/tlbMyiCwmbhHY9FWNkXPObO3xF30WMu+ksVmee+SRojWEPUfrXP+0RzqxskY RaRdvHnCaN9Uhnu3AgkBcArypuRqsoEF02Nae/zIr/OIDROVrQAoicdpMpLzT/e0QPh2 Y/FEu/KbEDb19WdXexYIYZ/YBWbhvx3Sf7WQhDoWwIdjucrP5qt1FWEyGsaGx/8fLYDR S5fIwvTmk8gk2FEwDKIs7SQat2v7w9fI8HMlnwrF+1Z/nKVnB1UvdMW3wlbk358O29cZ /x4zWC4Ihp96LgkcYWKNXui8P/lCcO1vsgqT+OasJ9I8Eq28/7uJUNT/tS9mcyjYhd57 7bXQ== 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; bh=hx3TEgY39elQOvRZKIYlQACZaQ3s3d5tMJmYsbA0qFg=; b=HTp1Y9BII6J/X2hiZpTmBLgbFREzvpOZIUl2WPpBX9ppMhuW+srGkT1OhMaDoHjfgS HH96a2Blk1LOAPfzY4MVVZ0B2TWZvT2RkJwjQgXnvCdE0RFStoYNgt60HnSstxdICIz4 82AHrh14jS/1FXRblyvgd6E8laDEvVjZt1YfVNMFwmYQ0Z1v0WvsCdYudLuyiUGToLGE VjbQbwrG/MkUUPfabUHh2HsZbCwSa6L4Kzc1Oiu3dIVdq1GyBgSGYtXMMnT31do3WJOP wi2r3Zsu8Eo+edd7Ri1wHM+n1R3ZgbDwBZ6DGZgf04DKx1Mpkv5Dj2lMxatgpShn/Zcx l81Q== X-Gm-Message-State: APjAAAWqxgdh2Taxs+xGWDAU0uh1aiGusBTzy56Dir74asl2qTNRmJCl e8rdUOdrl2GZPxle4IfptVU= X-Received: by 2002:a17:902:2929:: with SMTP id g38mr88476612plb.163.1564389413648; Mon, 29 Jul 2019 01:36:53 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id z19sm52920862pgv.35.2019.07.29.01.36.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 01:36:53 -0700 (PDT) From: Jia-Ju Bai To: alexander.deucher@amd.com, christian.koenig@amd.com, David1.Zhou@amd.com, airlied@linux.ie, daniel@ffwll.ch Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] gpu: drm: radeon: Fix a possible null-pointer dereference in radeon_connector_set_property() Date: Mon, 29 Jul 2019 16:36:44 +0800 Message-Id: <20190729083644.29160-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In radeon_connector_set_property(), there is an if statement on line 743 to check whether connector->encoder is NULL: if (connector->encoder) When connector->encoder is NULL, it is used on line 755: if (connector->encoder->crtc) Thus, a possible null-pointer dereference may occur. To fix this bug, connector->encoder is checked before being used. This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- drivers/gpu/drm/radeon/radeon_connectors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index c60d1a44d22a..b684cd719612 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -752,7 +752,7 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct radeon_encoder->output_csc = val; - if (connector->encoder->crtc) { + if (connector->encoder && connector->encoder->crtc) { struct drm_crtc *crtc = connector->encoder->crtc; struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); -- 2.17.0