Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7462677rwi; Mon, 24 Oct 2022 15:12:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/wp/hjJCDls7ewPwG0iq4BBiYqwIdeu91TBHZQ5b1bkNYgPX5UIdr6cD12ue10xKkXgtd X-Received: by 2002:a05:6402:2989:b0:44e:90d0:b9ff with SMTP id eq9-20020a056402298900b0044e90d0b9ffmr32530459edb.110.1666649538488; Mon, 24 Oct 2022 15:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666649538; cv=none; d=google.com; s=arc-20160816; b=nlrcsqH3tVCc8EAT94gguDpCZc73LdQJchXePnnTXQYB6/OPYsKc25sgS+9z/9BYqQ cogXqkuF5tyBUgwJL6QEEvibgj61wzjLyyBoMLjl+y1oe0hLDbkHYvq8x8X6L42cz9BI l6djSpPK6LAt8WJcjYnHHK5F9OLMyLTigOPchUaO1XHP7QVejMk+NEakprGhSoPVjQCU JOx041PSaMTqiMVRGfjy+fwHYPrsVTiHwVkDrCMgbxrvs/JsLOPePcPDgJjvNv71Niew AJ0LNCNHKJWNAXBpsNz+20P7SECBVH68S1Dcpwr9IlUhQ0ioJZuM1ee4fMjnom/Szahn sxkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZKqePUtERwiNpa9RU8NgZVmDvaIbmBIzrho3RAWbE04=; b=s6+7xwK7YxStlcuI6TV024YKXH93Q+st4ZYcoYL7rkO4NaFhuCjoJ7f2ltTi6UQfKC BtMifCmpY0OJZSesnSHRZ3JIpV1cN4KBojUErLp7JpH1k6jI1+n6QjVhZN/YMk1NYqWu vgomAoT2jK0fczlUHxG5NkRd5ItaG7OucYz1nZ0lwBncYpEErjUyo42xi+SPGr1bCt0o yvMVWx97OTf7nLP69q5DAj+iDYUq2/wVskab8JH/4sDfrBh3oHgJgx+TtoLHOs0w4WA6 ThPI2x26CZmffz97D2TCPPfqz3zw5XEH5QucUNxY56PPQDV6VkFk7qIJqmBMkVKoaRoD MOSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CuPfMEny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a1709064fcb00b0078df86528d3si728383ejw.99.2022.10.24.15.11.53; Mon, 24 Oct 2022 15:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CuPfMEny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbiJXU4Z (ORCPT + 99 others); Mon, 24 Oct 2022 16:56:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233989AbiJXU4D (ORCPT ); Mon, 24 Oct 2022 16:56:03 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495562C4C9E; Mon, 24 Oct 2022 12:02:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E8CB1B815B4; Mon, 24 Oct 2022 12:10:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4930DC43142; Mon, 24 Oct 2022 12:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613408; bh=G1iDAf3f6Jpdzk94UbQC3Rkti0Ys811hQbx2+MSiH9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CuPfMEny0Ift32isBMGhUf5Sb8cc6xfGJa3gcHy3iLipCswGQZ2pl8DhXaq8Aroxd DcV6cKisSGwUm6ZlY2C+3WwXBBkfBWYmwW7e1YZqVWib86lAm7322XgW8Z0ETNfzsW ZypnnrzQH1BF4mDYNLY64oW0T7iCggLKT47TUEAQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Robert Foss , Sasha Levin Subject: [PATCH 5.4 095/255] drm/bridge: megachips: Fix a null pointer dereference bug Date: Mon, 24 Oct 2022 13:30:05 +0200 Message-Id: <20221024113005.647585310@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit 1ff673333d46d2c1b053ebd0c1c7c7c79e36943e ] When removing the module we will get the following warning: [ 31.911505] i2c-core: driver [stdp2690-ge-b850v3-fw] unregistered [ 31.912484] general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN PTI [ 31.913338] KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] [ 31.915280] RIP: 0010:drm_bridge_remove+0x97/0x130 [ 31.921825] Call Trace: [ 31.922533] stdp4028_ge_b850v3_fw_remove+0x34/0x60 [megachips_stdpxxxx_ge_b850v3_fw] [ 31.923139] i2c_device_remove+0x181/0x1f0 The two bridges (stdp2690, stdp4028) do not probe at the same time, so the driver does not call ge_b850v3_resgiter() when probing, causing the driver to try to remove the object that has not been initialized. Fix this by checking whether both the bridges are probed. Fixes: 11632d4aa2b3 ("drm/bridge: megachips: Ensure both bridges are probed before registration") Signed-off-by: Zheyu Ma Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/20220830073450.1897020-1-zheyuma97@gmail.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c index 5302dd90a7a5..b72f6f541d4e 100644 --- a/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c +++ b/drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c @@ -279,7 +279,9 @@ static void ge_b850v3_lvds_remove(void) * This check is to avoid both the drivers * removing the bridge in their remove() function */ - if (!ge_b850v3_lvds_ptr) + if (!ge_b850v3_lvds_ptr || + !ge_b850v3_lvds_ptr->stdp2690_i2c || + !ge_b850v3_lvds_ptr->stdp4028_i2c) goto out; drm_bridge_remove(&ge_b850v3_lvds_ptr->bridge); -- 2.35.1