From patchwork Fri Oct 5 21:59:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 10628827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BB761731 for ; Fri, 5 Oct 2018 22:01:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B3D29AC2 for ; Fri, 5 Oct 2018 22:01:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59D8A29ACF; Fri, 5 Oct 2018 22:01:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E8E3B29AC2 for ; Fri, 5 Oct 2018 22:01:01 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=6M9/l99dIpes6JtfzDgBdCW8kBq1wsjQKnH9rwEF2xE=; b=HI1B1tV61KWyrCDiM080Ob0RH4 2EZFNnPG493/iUj2Ba4vKX2POV0XiOzZ3smJjf2TKXif927P8wpvJOQzWoZtVqmncDmGQf0Y4p+D/ lKYP5Dcs9k0UbGeIZlzK1KfzFBPXa5Ldq8xKSYltBqoHKQej97n3DWMsgcoYFCrXfzW+ibA5/WCvu GwyO4O4BqB6f5/ZqtBgx+MU6HZadiic1C5eNSMYrslm94ZOrsVBE67IhhqrxmGUrZ+IaJTeBv+rqU eoXhX2bHMulJsfRxBml1bzdcWcf25feGoRkx+Ww7/XPMV6X4fU8FlhcJx8DpKJ2HIQobGp28BthJK vHd7nnTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Y9R-0006yk-7F; Fri, 05 Oct 2018 22:00:49 +0000 Received: from mail.micronovasrl.com ([212.103.203.10]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Y8k-0005US-EV for linux-arm-kernel@lists.infradead.org; Fri, 05 Oct 2018 22:00:08 +0000 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 4A8F9B00767 for ; Fri, 5 Oct 2018 23:59:55 +0200 (CEST) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=references:in-reply-to:x-mailer:message-id:date:date:subject :subject:to:from:from; s=dkim; t=1538776794; x=1539640795; bh=6I LxoHv50N8w16qw34Fi8S7zwu/gJ947bOekxAMNcUc=; b=bA1UwPx6Nkh4YzY4gw lHyJWtTP+xFE3VDejc4jKU90ArfMtuo321gMbtnQ/ONTnHV4wZal6NFWwl6Vc5Hp pA22hvOHkPPSqjRaZ7xyFL8mkzJX/IkepRWDmhK2kSfmGmPDxCbnCYGRXjF7wap5 4tXX6bIIublldBV4gEQyNjI5o= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uH1xpNQP-3QX for ; Fri, 5 Oct 2018 23:59:54 +0200 (CEST) Received: from ubuntu.localdomain (unknown [192.168.123.60]) by mail.micronovasrl.com (Postfix) with ESMTPSA id BB698B000F6; Fri, 5 Oct 2018 23:59:53 +0200 (CEST) From: Giulio Benetti To: Maxime Ripard Subject: [PATCH v3 1/2] drm/sun4i: tcon: fix check of tcon->panel null pointer Date: Fri, 5 Oct 2018 23:59:50 +0200 Message-Id: <20181005215951.99003-1-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181004195605.txvbkshvxklyzxyb@flea> References: <20181004195605.txvbkshvxklyzxyb@flea> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181005_150006_691481_574E6C4A X-CRM114-Status: GOOD ( 25.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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, Chen-Yu Tsai , Giulio Benetti , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since tcon->panel is a pointer returned by of_drm_find_panel() need to check if it is not NULL, hence a valid pointer. IS_ERR() instead checks return error values, not NULL pointers. Substitute "if (!IS_ERR(tcon->panel))" with "if (tcon->panel)". Signed-off-by: Giulio Benetti --- Changes V1->V2: * correct same bug for all same occurences in drm/sun4i folder Changes V2->V3: * Improve commit log drivers/gpu/drm/sun4i/sun4i_lvds.c | 4 ++-- drivers/gpu/drm/sun4i/sun4i_rgb.c | 4 ++-- drivers/gpu/drm/sun4i/sun4i_tcon.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_lvds.c b/drivers/gpu/drm/sun4i/sun4i_lvds.c index af7dcb6da351..e7eb0d1e17be 100644 --- a/drivers/gpu/drm/sun4i/sun4i_lvds.c +++ b/drivers/gpu/drm/sun4i/sun4i_lvds.c @@ -75,7 +75,7 @@ static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder) DRM_DEBUG_DRIVER("Enabling LVDS output\n"); - if (!IS_ERR(tcon->panel)) { + if (tcon->panel) { drm_panel_prepare(tcon->panel); drm_panel_enable(tcon->panel); } @@ -88,7 +88,7 @@ static void sun4i_lvds_encoder_disable(struct drm_encoder *encoder) DRM_DEBUG_DRIVER("Disabling LVDS output\n"); - if (!IS_ERR(tcon->panel)) { + if (tcon->panel) { drm_panel_disable(tcon->panel); drm_panel_unprepare(tcon->panel); } diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c index bf068da6b12e..f4a22689eb54 100644 --- a/drivers/gpu/drm/sun4i/sun4i_rgb.c +++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c @@ -135,7 +135,7 @@ static void sun4i_rgb_encoder_enable(struct drm_encoder *encoder) DRM_DEBUG_DRIVER("Enabling RGB output\n"); - if (!IS_ERR(tcon->panel)) { + if (tcon->panel) { drm_panel_prepare(tcon->panel); drm_panel_enable(tcon->panel); } @@ -148,7 +148,7 @@ static void sun4i_rgb_encoder_disable(struct drm_encoder *encoder) DRM_DEBUG_DRIVER("Disabling RGB output\n"); - if (!IS_ERR(tcon->panel)) { + if (tcon->panel) { drm_panel_disable(tcon->panel); drm_panel_unprepare(tcon->panel); } diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index c78cd35a1294..e4b3bd0307ef 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -555,7 +555,7 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, * Following code is a way to avoid quirks all around TCON * and DOTCLOCK drivers. */ - if (!IS_ERR(tcon->panel)) { + if (tcon->panel) { struct drm_panel *panel = tcon->panel; struct drm_connector *connector = panel->connector; struct drm_display_info display_info = connector->display_info; From patchwork Fri Oct 5 21:59:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 10628825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F0631515 for ; Fri, 5 Oct 2018 22:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4D729AC2 for ; Fri, 5 Oct 2018 22:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EC6229ACF; Fri, 5 Oct 2018 22:00:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B02129AC2 for ; Fri, 5 Oct 2018 22:00:22 +0000 (UTC) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=961otpxcbbtJBmtSptYmeLU3juN7TZTc25toYSmN0ZQ=; b=Nd/LsGpeJ3jXeKGaXE5CvmVXNc m6YxLUlRBOkFuih/F5KKY859l88GrXNTm/FnybZd8RzJk7eK7SNXv/IX3+OBYOGn2LwFFMKJsyvKu yIO+RYwj/dR5RJPOY3QLG4qx2tUd1y9/+uyJZ4e6y1dmRhqmvF8B+oEM560/f1aNxawKl6kl3460a 5NFRY0WRumBugWx2KjPHBI6kKxJflNrxdscLwI3kU0CxyZEXAaI5YPAsAujYkFMJdS9e3fz17yFvT ClyuV8v/xUxoBgTzp9BYt0ZaPmmmpK6zscvjGPWRnm7Kh2x2QyDGUJ2M6FyMbv/oSIYJs+BKdg+D2 oeKeNKng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Y8o-0005v7-QN; Fri, 05 Oct 2018 22:00:10 +0000 Received: from mail.micronovasrl.com ([212.103.203.10]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g8Y8k-0005UT-EV for linux-arm-kernel@lists.infradead.org; Fri, 05 Oct 2018 22:00:08 +0000 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id 513DEB00737 for ; Fri, 5 Oct 2018 23:59:56 +0200 (CEST) Authentication-Results: mail.micronovasrl.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=micronovasrl.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=micronovasrl.com; h=references:in-reply-to:x-mailer:message-id:date:date:subject :subject:to:from:from; s=dkim; t=1538776795; x=1539640796; bh=RT dTDc9aj5yU4rsjgtCJV/wCZutXTyJKHh4YN8AE/DM=; b=PfA88pu1Ubco24Rq4B YjfcW7+gNS4SfYi8Q2xN1YAVMHa1hsjytQGdXv70DoDQviZmIjOkt3cCCDPpey9j Ncor0XJ9F0dyqKJ07EYls3SPbMM0i5Ar9+/NS5uSv3SrHu1JvSz+utO0hPImu4mN 1Oi38+4mfOzUDVVVJXK41XX1g= X-Virus-Scanned: Debian amavisd-new at mail.micronovasrl.com Received: from mail.micronovasrl.com ([127.0.0.1]) by mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HKMmFcSjB_qT for ; Fri, 5 Oct 2018 23:59:55 +0200 (CEST) Received: from ubuntu.localdomain (unknown [192.168.123.60]) by mail.micronovasrl.com (Postfix) with ESMTPSA id 29F3FB0040F; Fri, 5 Oct 2018 23:59:54 +0200 (CEST) From: Giulio Benetti To: Maxime Ripard Subject: [PATCH v3 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if NULL Date: Fri, 5 Oct 2018 23:59:51 +0200 Message-Id: <20181005215951.99003-2-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005215951.99003-1-giulio.benetti@micronovasrl.com> References: <20181004195605.txvbkshvxklyzxyb@flea> <20181005215951.99003-1-giulio.benetti@micronovasrl.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181005_150006_685026_8C179292 X-CRM114-Status: GOOD ( 24.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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, Chen-Yu Tsai , Giulio Benetti , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If tcon->panel pointer is NULL, trying to dereference from it (i.e. tcon->panel->connector) will cause a null pointer dereference. Add tcon->panel null pointer check before calling sun4i_tcon0_mode_set_dithering(). Signed-off-by: Giulio Benetti Fixes: f11adcecbd5f ("drm/sun4i: tcon: Add dithering support for RGB565/RGB666 LCD panels") Reviewed-by: Chen-Yu Tsai --- Changes V1->V2: * None Changes V2->V3: * Rewrite commit log drivers/gpu/drm/sun4i/sun4i_tcon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index e4b3bd0307ef..f949287d926c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -491,7 +491,8 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, sun4i_tcon0_mode_set_common(tcon, mode); /* Set dithering if needed */ - sun4i_tcon0_mode_set_dithering(tcon, tcon->panel->connector); + if (tcon->panel) + sun4i_tcon0_mode_set_dithering(tcon, tcon->panel->connector); /* Adjust clock delay */ clk_delay = sun4i_tcon_get_clk_delay(mode, 0);