From patchwork Tue Oct 2 21:59:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giulio Benetti X-Patchwork-Id: 10624129 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 5A6A3174E for ; Tue, 2 Oct 2018 21:59:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F67128305 for ; Tue, 2 Oct 2018 21:59:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 435822846F; Tue, 2 Oct 2018 21:59:45 +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 DC3F428305 for ; Tue, 2 Oct 2018 21:59:44 +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=NIJydSteUgHFUnNxR1oaDHqnK6qv1cypEv+OdmIcsXg=; b=llSfa10z21jbmgGKI1uyNIA6Qb K/+1MOEciXbQJjJ42BJ/QhFUslISiFY6J1ItVReowZCREHoEJMtpLfF0D6sOlqct7gpU4Vs2PKtFB SYzEvKyqaqvFdooTk2hch+rC/JOZIsN9S+53X+WHamEFX2EntwS7ZRlOKTHxELcRmTc5Ao1MR03Ub FQJW7hUeCKqSAlNKcy1U54LtwDACHQ+wYnYNr63+TLi2bia7Hvg3zO0vG1QJhB32UwIfWGN9r1RUX FeMEjnz4kiEeP8yg+dmWRw80ERNWlyvL3XA7gdEDZJerKDilnnsvBwWcxE3Rf/NpkFrxzhfbEArjy eNa+CZXA==; 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 1g7Shf-0007a6-Ta; Tue, 02 Oct 2018 21:59:39 +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 1g7Shb-0007YI-M2 for linux-arm-kernel@lists.infradead.org; Tue, 02 Oct 2018 21:59:37 +0000 Received: from mail.micronovasrl.com (mail.micronovasrl.com [127.0.0.1]) by mail.micronovasrl.com (Postfix) with ESMTP id BC066B00B49 for ; Tue, 2 Oct 2018 23:59:22 +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=1538517562; x=1539381563; bh=4F HVT5NrrG/QTe2Mj+ppLwr5ncrmz/fzttP4uUPdogc=; b=DAtr3yRK22EQBy7xQq pDYfF6I6uvGA9K+e3Y/nczV/VeNDsWkPoLVDYKZdd9wJf0y+mzy0S1heaqBNZZyp 0PfJCJuWaD+rwgbiVno0XgskYT/3xkDNAwDsp8RuZxKUl5eYsz/1FlEgmqQz0zWi U75I01TLX6fClc4zdedvkaqjI= 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 TO_aaJsbwkfz for ; Tue, 2 Oct 2018 23:59:22 +0200 (CEST) Received: from ubuntu.localdomain (146-241-101-147.dyn.eolo.it [146.241.101.147]) by mail.micronovasrl.com (Postfix) with ESMTPSA id B4A03B00A71; Tue, 2 Oct 2018 23:59:20 +0200 (CEST) From: Giulio Benetti To: Maxime Ripard Subject: [PATCH 2/2] drm/sun4i: tcon: prevent tcon->panel dereference if null Date: Tue, 2 Oct 2018 23:59:17 +0200 Message-Id: <20181002215917.1849-2-giulio.benetti@micronovasrl.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002215917.1849-1-giulio.benetti@micronovasrl.com> References: <20181001093612.GA13672@mwanda> <20181002215917.1849-1-giulio.benetti@micronovasrl.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181002_145935_924467_4A00437F X-CRM114-Status: GOOD ( 24.62 ) 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 , linux-arm-kernel@lists.infradead.org, Giulio Benetti , Dan Carpenter 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 using tcon with VGA, tcon->panel will be null(0), this will cause segmentation fault when trying to dereference tcon->panel->connector. Add tcon->panel null check before calling sun4i_tcon0_mode_set_dithering(). Signed-off-by: Giulio Benetti Reviewed-by: Chen-Yu Tsai --- 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);