From patchwork Thu Jan 9 07:29:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 11325125 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 742A46C1 for ; Thu, 9 Jan 2020 07:29:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 368AB20673 for ; Thu, 9 Jan 2020 07:29:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="K/HYL4Qk"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ej7W8jgc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 368AB20673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eA1Z8AJsye9e/ViYKl1DI6MN+FcgmhsrpBD+6zvew9A=; b=K/HYL4Qkq2sEIi 3bZ9uIk6GO3PqOlXq9jM3eVZ/w1cQI8UVjL2kzWAAKQ0EYSb4AntlxD4jz9qCauGi+aj79AACyCS1 2c5FWBUSEkAKlSs8dbyzYBw1FRH0+oYuCs77FPEdVYQaBxJKz/6Gphdgq9K4jf0h0Y0Up27EwH5zG oYlXjRoaf4weEcv4hduL6ZkMHqKSHMMxBLJtG/mCB5rpHKiQfFBnTGJsUqHMXZODgrHK+gUTwYmMJ ttzMCAK56Lrbt0zSlHgS5OH3+OQ6y5owCTXH8p9JyWeyZut915rBY34uJnEJ41Xc8PV0vGiN4BWvU rgg3hv9olDCe8Gz5f4Sg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipSG9-0006Bu-6e; Thu, 09 Jan 2020 07:29:37 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ipSFh-0005p2-9a for linux-arm-kernel@lists.infradead.org; Thu, 09 Jan 2020 07:29:12 +0000 Received: by mail-pl1-x644.google.com with SMTP id p9so2199039plk.9 for ; Wed, 08 Jan 2020 23:29:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eb7+4YTwZPIai1tsUX2MFyulW3TpuQQ3q3lzwkxFRow=; b=ej7W8jgc7Qi2towEQUvPZ+HLF2Kev1VG8RzMxUS5owrJ4eTxi+Kf8XMBBX1iBsQitC eMtse3kYPa4wXtk2TSBcfd623EMdWEZsk9Axr5HnIgKhJq6g/bsv/a13TdoLdyZ/A65g p27LdFxT3wMG4atcUFXFjF4Wx7gKd7Yo4MlIc= 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=eb7+4YTwZPIai1tsUX2MFyulW3TpuQQ3q3lzwkxFRow=; b=ZXN82O4bEzLM5y9a4e/MCVZeypfRYsztXvnRbMqCDzU5Fqj46GSgvSsDRhj0vXPMbe aI8mEFW8RYOZ60fe8KC7eWdKTeU7aM4j10RPJcXftV6jOx73gmnpAkF3d4qtV3NW6anM phSh1hrD1tcS7Qakk0ON4I76p+CD6dlZuBwH7GJp5e6g7/CNqPZz/Vv/bqRSIZdnsd3+ hRmDILdNPwN6Vcx759VyVGMBjTdm2oHI4UezX3te7PzoAhG4edrYS9UqobuYTkhFgcJt r3C0vHoihTUXzS4IAjyrMwpvGfJTnDxewqYpvqLUqxxw802ANhwQ8GNnZ4ICjkNoFM9+ 778A== X-Gm-Message-State: APjAAAXPFC/VHMo17q//eU/Wa4zFkorZ7CUJ2IvD8MwDnTHofrsvoedo P9qsQdflXT1HqmrunYEcpHqqmg== X-Google-Smtp-Source: APXvYqxyorOub/tc3oX4xjM6D+1C5Oaw62atk5hhMqHpFC6EWGkz1ky0e/G5dlHrY0x2U1r+CwOnrQ== X-Received: by 2002:a17:90a:9284:: with SMTP id n4mr3519891pjo.84.1578554947811; Wed, 08 Jan 2020 23:29:07 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id p16sm6485810pfq.184.2020.01.08.23.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2020 23:29:07 -0800 (PST) From: Hsin-Yi Wang To: CK Hu Subject: [PATCH] drm/mediatek: check for comp->funcs Date: Thu, 9 Jan 2020 15:29:00 +0800 Message-Id: <20200109072900.17988-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.25.0.rc1.283.g88dfdc4193-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200108_232909_392394_8A8D8F53 X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, Philipp Zabel , Matthias Brugger , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org There might be some comp that doesn't have funcs, eg. hdmi-connector. Check for comp->funcs otherwise there will be NULL pointer dereference crash. Fixes: bd3de8cd782b ("drm/mediatek: Add gamma property according to hardware capability") Fixes: 7395eab077f9 ("drm/mediatek: Add ctm property support") Signed-off-by: Hsin-Yi Wang --- This patch is based on mediatek's drm branch: https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-next-5.6 After https://patchwork.freedesktop.org/patch/344477/?series=63328&rev=59, there will also be funcs for hdmi-connector. --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index fb142fcfc353..7b392d6c71cc 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -808,11 +808,13 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->ddp_comp[i] = comp; - if (comp->funcs->ctm_set) - has_ctm = true; + if (comp->funcs) { + if (comp->funcs->ctm_set) + has_ctm = true; - if (comp->funcs->gamma_set) - gamma_lut_size = MTK_LUT_SIZE; + if (comp->funcs->gamma_set) + gamma_lut_size = MTK_LUT_SIZE; + } } for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)