Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2457798ybc; Sun, 17 Nov 2019 22:20:08 -0800 (PST) X-Google-Smtp-Source: APXvYqz1hWsOMG1hy4X0Xy5hzoLgxzQdrQ6lIEkytY0STCrp8I1Nbob0+J4S3pP8KmjMX3Q4Gtn/ X-Received: by 2002:a17:906:2241:: with SMTP id 1mr1705628ejr.16.1574058008355; Sun, 17 Nov 2019 22:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574058008; cv=none; d=google.com; s=arc-20160816; b=k3P/txJcYNoo8bX0RVyZ/dWiJIqFwr+SmKUf789QTTmExgqeQmymNIpi6+wEhJhdcY GClEAUwviMPwvbhmygBmSYIbFg2f0RCJ5QItLQge+/TWT3P5be5zh1jZzMVDGoHS1rAl 1wxTXHUNaIiNtLhvL/8b3YuQOmEwjlkz/y4GlgEYmKS52esyCnwKrPqae4ygZQBvMYkw DilSqc6J+EnS7kO7zYMw+TxZzs1PdeHYd8xtMne33AQ8j3c0TYuQ0tZ3mULW7ENg5zZW I5y5kt79EOLNb6BphUZVFG4PRlNp1+4HGImHml1csADAUnpBcMD5paJYlCAx2J0wAhQm fV3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=In3dXboSGxSDc4571/sMxtCG8no6hvyudyiC85O5ndo=; b=w9iJo9b7Hh/ChLNKq/5O1VmAnsZvuWCQOQR3DitFzR9C8eaahnGjUO4M/H2sxpTfDl Eq2uemgnI0otx6h3NKlhIgIKJs4trX4QhYXa94ciChpF2CAszyPBOBHzIHaAwhSKVzIs e92W6LS1BzZ/BT6Aaz6kOP6lXRnmjiKVVIB2Bmy0NP5sV6EtT+uUd/o3i1kjGxJ33gYJ 5fnQO2idEhAi1ZfearkqCe07MV1K65bTbY1qQOt043IieijqK6hWyWsIzEnpQOAtbAwv SU6ZP0jWRV/kbzGxm/9sa46wviCe+Ghd2viopdBylNYS/pWWwzjUkrrG5NWMHZyVmauN z9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b="BXpHZhA/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si492861edy.171.2019.11.17.22.19.45; Sun, 17 Nov 2019 22:20:08 -0800 (PST) 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=fail header.i=@chromium.org header.s=google header.b="BXpHZhA/"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbfKRGSg (ORCPT + 99 others); Mon, 18 Nov 2019 01:18:36 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34008 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbfKRGSg (ORCPT ); Mon, 18 Nov 2019 01:18:36 -0500 Received: by mail-pl1-f194.google.com with SMTP id h13so9184458plr.1 for ; Sun, 17 Nov 2019 22:18:36 -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=In3dXboSGxSDc4571/sMxtCG8no6hvyudyiC85O5ndo=; b=BXpHZhA/xlBopIauk0uUtCcrKTLJpeohwqpkdx+pyeB6cHC23OkMv5szao3WoFQgWG bpGQhs8COapoRUFUUwCikZIhzDyoPIVni7BgFnJxCR8+nXcXKRftiZoiC0dq8IG2LBaL aXBBWuLKQw+ZwkDv48ctSYKopX322s7+2kZLY= 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=In3dXboSGxSDc4571/sMxtCG8no6hvyudyiC85O5ndo=; b=WXchEEwRMpIB5UYI7qggeOpkV34QJxjkTsEXE9RS2xJQK+CT5HffdKoKq6s5Yimgvy XbMWgOeothCIIEIsSC/ntpUtra8EDF5fWovlspVxCQX3IlU1Fe5777tIQ9PlEUuQP8/g tYPjiYuDLGbkGFDv8z6Q6QanHZrIHXwIedvWDGwjPoYnZJWQHyWRxnFonrCMheH/CfQ0 aWc0c64wn1npPrbGZ9lD2Zbo72OBer7kKlyHG2MA5F9hDDfBuSR0ZDjRh26hmsxt42Zk B3pPvMvR2Lo+LHbKFu4tjPv2LLf1if35r54BmUqvdufxXksqsW/DsFQRR1C/PAwR9mB6 BEnA== X-Gm-Message-State: APjAAAXSuOQLHP6HiO//tAnaXDEE1fexiqHz5iU/OO8ps1otsvCvz7ug EztvQx5redUyQpO+t/C0SIqVcg== X-Received: by 2002:a17:902:8f98:: with SMTP id z24mr21453839plo.35.1574057915737; Sun, 17 Nov 2019 22:18:35 -0800 (PST) Received: from pihsun-z840.tpe.corp.google.com ([2401:fa00:1:10:7889:7a43:f899:134c]) by smtp.googlemail.com with ESMTPSA id g4sm18589682pfh.172.2019.11.17.22.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 22:18:35 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , CK Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , Sean Paul , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR MEDIATEK), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/mediatek: Check return value of mtk_drm_ddp_comp_for_plane. Date: Mon, 18 Nov 2019 14:18:05 +0800 Message-Id: <20191118061806.52781-1-pihsun@chromium.org> X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mtk_drm_ddp_comp_for_plane can return NULL, but the usage doesn't check for it. Add check for it. Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a plane") Signed-off-by: Pi-Hsun Shih --- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index f80a8ba75977..4c4f976c994e 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -310,7 +310,9 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) plane_state = to_mtk_plane_state(plane->state); comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); - mtk_ddp_comp_layer_config(comp, local_layer, plane_state); + if (comp) + mtk_ddp_comp_layer_config(comp, local_layer, + plane_state); } return 0; @@ -386,8 +388,9 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); - mtk_ddp_comp_layer_config(comp, local_layer, - plane_state); + if (comp) + mtk_ddp_comp_layer_config(comp, local_layer, + plane_state); plane_state->pending.config = false; } mtk_crtc->pending_planes = false; @@ -401,7 +404,9 @@ int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane, struct mtk_ddp_comp *comp; comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer); - return mtk_ddp_comp_layer_check(comp, local_layer, state); + if (comp) + return mtk_ddp_comp_layer_check(comp, local_layer, state); + return 0; } static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc, base-commit: 5a6fcbeabe3e20459ed8504690b2515dacc5246f -- 2.24.0.432.g9d3f5f5b63-goog