From patchwork Fri Jan 21 13:12:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 12719682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 76A32C433EF for ; Fri, 21 Jan 2022 13:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=/tQ8Oetgb8t250gjkbQaa1ruDoyi/bWCWY2jf2WXUlU=; b=iyBVwRXjJoG4sJ YiRw+aaYbMB+BK81Xwrah9v7ovAIIOpMI0tbXPraNtJns5+uxZ9ReEwZK36Glv3JjDpUrP19cZ/pu n6a02KOo1T58y0jFc7dHl85rrPLP3K3FAsLjRWBdabLxvjfu0a3x6zuaZDpXcmcEVgnvWMvxvWlmR Wvji030Cxbahml6pIAC4fPOHIqb3Iys7Z/Z2WmIixPBd/0cFISw2POFWDyvdEqxSQYwvhDAll5D4E y/IcMczWxHOqR83CQi2T694otGCGuwYLniLR8Gs2/ehVJRRcgO5oy3FACay/C49fnXIxywSC8I8hs obXby3mJ8kKagbWGv+QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAtik-00F32O-M1; Fri, 21 Jan 2022 13:12:50 +0000 Received: from mx1.tq-group.com ([93.104.207.81]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAtig-00F312-RE for linux-arm-kernel@lists.infradead.org; Fri, 21 Jan 2022 13:12:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1642770766; x=1674306766; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fEz+hHnADLv4ib39sL6qVqJLUtABr6G2rfYbgY7Ght4=; b=dLCoOXV3awknPQmMZdgIG23YrY69f8LS+8AQ7ULo/Z88KRVYgr4rpDxD hy4HZU8d94WmJgwy35JBg/CIRwiYaqDc6xTEuIxx8dF3a6DvOxXKS8iIR Zqj44Z8DsE5KMWyN9dVA7UizGK4ldZq2YB3mi4sKe+dV4gkBLhaRhojGk 46MYkkPaA2y1TVwwRIwcmBsJJ1ix0APCm1lxdlO9U0w4YnMZo6/1TwcLY 0ThwYok9VkIGPtJCx9Ik+z3h2lpxSWkO1IMVtulozLnH1YO+xJsIlXmin 1pz04VAkyjW0YlsmZ9oGafATYx8C1zkCTRUtnhvlpyTxLXtdsTWRaKx0B w==; X-IronPort-AV: E=Sophos;i="5.88,304,1635199200"; d="scan'208";a="21640633" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 21 Jan 2022 14:12:43 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Fri, 21 Jan 2022 14:12:43 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Fri, 21 Jan 2022 14:12:43 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1642770763; x=1674306763; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fEz+hHnADLv4ib39sL6qVqJLUtABr6G2rfYbgY7Ght4=; b=oY/6f5/ymVgNpp6/E0AXfpvvr8Gl2ccSeU/NAqhRZu3jegTeBQXeP4IV zNcHu/beHAl71USyV6fNHn5ZQhcl7f72my9j7ec+WpUWd7PKmBFEdrGuA m8kN16bLv623O+s+BlYJPiyrRUu4Babw65cRwv3j2sShVxFb87bNUz/xG 8J+zmzm/tB4T4j6Vr93p8KCju1DFHfDJIZFErhTmfVJrBmmgQ7JeA6fas dspDodqqHhVec6eyP/t9sGUUQLDwN+6ucW6sPe8cvQB0RLq2oc0aA1J/+ lB4b86D7cSX3dwVeOp+Nb4brdgEiCLesrz7yI2PZY2fyM5tAyYowzR5l6 Q==; X-IronPort-AV: E=Sophos;i="5.88,304,1635199200"; d="scan'208";a="21640632" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 21 Jan 2022 14:12:43 +0100 Received: from steina-w.tq-net.de (unknown [10.123.49.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id F4042280065; Fri, 21 Jan 2022 14:12:42 +0100 (CET) From: Alexander Stein To: Marek Vasut , Stefan Agner , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Fabio Estevam Cc: Alexander Stein , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH 1/1] drm: mxsfb: Fix NULL pointer dereference Date: Fri, 21 Jan 2022 14:12:38 +0100 Message-Id: <20220121131238.507567-1-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220121_051247_254676_9C796554 X-CRM114-Status: GOOD ( 13.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Do not deference the NULL pointer if the bridge does not return a bridge state. Assume a fixed format instead. Fixes: commit b776b0f00f24 ("drm: mxsfb: Use bus_format from the nearest bridge if present") Signed-off-by: Alexander Stein --- This can happen if a "ti,sn75lvds83", "lvds-encoder" bridge is attached to it. atomic_get_input_bus_fmts is only implemented for the lvds-decoder case. drivers/gpu/drm/mxsfb/mxsfb_kms.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 0655582ae8ed..4cfb6c001679 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -361,7 +361,11 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, bridge_state = drm_atomic_get_new_bridge_state(state, mxsfb->bridge); - bus_format = bridge_state->input_bus_cfg.format; + if (!bridge_state) + bus_format = MEDIA_BUS_FMT_FIXED; + else + bus_format = bridge_state->input_bus_cfg.format; + if (bus_format == MEDIA_BUS_FMT_FIXED) { dev_warn_once(drm->dev, "Bridge does not provide bus format, assuming MEDIA_BUS_FMT_RGB888_1X24.\n"