From patchwork Mon Oct 24 11:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9538 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp485440wru; Mon, 24 Oct 2022 07:31:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5p1/GlseSKDCeiwuJidJekpt2r105hsQmXboP3reBLr0t2TP/sY3uDw/Mv9ccBApvI8GyY X-Received: by 2002:a63:91ca:0:b0:460:c58f:3127 with SMTP id l193-20020a6391ca000000b00460c58f3127mr28799467pge.31.1666621914533; Mon, 24 Oct 2022 07:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621914; cv=none; d=google.com; s=arc-20160816; b=yTBw8QoJ5ADLzo2T2G+0/uto6v3+jH6SKPf3Vz/jqGh6A+j0JJkuBcKnx/XSlAPc9P 0qUzk9e3Ig74/GbvSkJE3H40o5dJFaX4vgCuN72vGFs7TM98JEmMEoB+m7HZOu5qujO7 Jba+WeAMCSvl62auUN+R9pfj/us8MS7/G1tw0snehQxEDR5ZV0oOYnnzkhferNSjmyMT 9nIeCtR0hjlHqaWhjvhUM1hp6JqtlgWINvrPBPl3rENAOo8b88IFvEdWV5ZJhLhGnL0c JEGPyWEJOyBhYqKyKB5hz2WkmbkQWuT0P45ahyGp97GDdxgftEhnBUi3Bi5f+uVy9jwE dENQ== 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=eQoiZIOG8jVaOlScgXa9R7M3ugQogyl1aUv3BsFVxNo=; b=xHvYLfYpxTdkrmue2tzpc2VokfLZhlVZ6AmwYjZ040tlVk8KmzJx2zLvfLuVo/K6Du yTRKh//pm0esT0K3eXgNG/i0WV9XAWJRjbRjQuyUubA85IJXdVGahDInAy5cyFtA4hju is0G0ETH/x4wi7xtj/n2PJUPQfpBa2ijbZfQxQQrlhq/LI4Xh3Ol00z0QXi0M/ayS8Qh /Vm9d4B7cDVz94cEzbiOgTsNXOeGXJhPFYH5dKKPGpl+F35RgpweySsVKzSyvEqo7YcQ WC8cBn+d6b9czGpEOQK4xDCz1ahPjqd6e69rS7wyCwp54xgGspDE7c3QOmndE7sUQe8E swzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QpE6+O4s; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pv14-20020a17090b3c8e00b0020a774637a6si9194867pjb.67.2022.10.24.07.31.40; Mon, 24 Oct 2022 07:31:54 -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=QpE6+O4s; 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 S237030AbiJXO1R (ORCPT + 99 others); Mon, 24 Oct 2022 10:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237038AbiJXO0Z (ORCPT ); Mon, 24 Oct 2022 10:26:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E5217CAB8; Mon, 24 Oct 2022 06:00:23 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AA1E4612E3; Mon, 24 Oct 2022 12:42:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3A3AC433D6; Mon, 24 Oct 2022 12:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615327; bh=dkoTc/zMPa5N/E5aoAr0YI9KEZG1XSiD+8f85JZC6+M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpE6+O4swaCzz6G14fW2nzgmx/OqFWGaSjSG5y/0hsB/7XomVMtul8pIclCVYiUQg ZWAhKsG5V2/8iR41zA7x4Dqwo9tMOBh95rE+Rpv1lyBI96KeHnFd99zdRjliS4m4/H 24DXxUYADFI8tmvUaTgfIkA6ialwIvwGtfQvuET8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?utf-8?q?Alvin_=C5=A0ipraga?= , Robert Foss , Sasha Levin Subject: [PATCH 5.15 209/530] drm: bridge: adv7511: unregister cec i2c device after cec adapter Date: Mon, 24 Oct 2022 13:29:13 +0200 Message-Id: <20221024113054.536714973@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579740500800758?= X-GMAIL-MSGID: =?utf-8?q?1747579740500800758?= From: Alvin Šipraga [ Upstream commit 40cdb02cb9f965732eb543d47f15bef8d10f0f5f ] cec_unregister_adapter() assumes that the underlying adapter ops are callable. For example, if the CEC adapter currently has a valid physical address, then the unregistration procedure will invalidate the physical address by setting it to f.f.f.f. Whence the following kernel oops observed after removing the adv7511 module: Unable to handle kernel execution of user memory at virtual address 0000000000000000 Internal error: Oops: 86000004 [#1] PREEMPT_RT SMP Call trace: 0x0 adv7511_cec_adap_log_addr+0x1ac/0x1c8 [adv7511] cec_adap_unconfigure+0x44/0x90 [cec] __cec_s_phys_addr.part.0+0x68/0x230 [cec] __cec_s_phys_addr+0x40/0x50 [cec] cec_unregister_adapter+0xb4/0x118 [cec] adv7511_remove+0x60/0x90 [adv7511] i2c_device_remove+0x34/0xe0 device_release_driver_internal+0x114/0x1f0 driver_detach+0x54/0xe0 bus_remove_driver+0x60/0xd8 driver_unregister+0x34/0x60 i2c_del_driver+0x2c/0x68 adv7511_exit+0x1c/0x67c [adv7511] __arm64_sys_delete_module+0x154/0x288 invoke_syscall+0x48/0x100 el0_svc_common.constprop.0+0x48/0xe8 do_el0_svc+0x28/0x88 el0_svc+0x1c/0x50 el0t_64_sync_handler+0xa8/0xb0 el0t_64_sync+0x15c/0x160 Code: bad PC value ---[ end trace 0000000000000000 ]--- Protect against this scenario by unregistering i2c_cec after unregistering the CEC adapter. Duly disable the CEC clock afterwards too. Fixes: 3b1b975003e4 ("drm: adv7511/33: add HDMI CEC support") Signed-off-by: Alvin Šipraga Reviewed-by: Robert Foss Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/20220612144854.2223873-3-alvin@pqrs.dk Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index 7e3f6633f255..3dc551d223d6 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1326,8 +1326,6 @@ static int adv7511_remove(struct i2c_client *i2c) if (adv7511->type == ADV7533 || adv7511->type == ADV7535) adv7533_detach_dsi(adv7511); - i2c_unregister_device(adv7511->i2c_cec); - clk_disable_unprepare(adv7511->cec_clk); adv7511_uninit_regulators(adv7511); @@ -1336,6 +1334,8 @@ static int adv7511_remove(struct i2c_client *i2c) adv7511_audio_exit(adv7511); cec_unregister_adapter(adv7511->cec_adap); + i2c_unregister_device(adv7511->i2c_cec); + clk_disable_unprepare(adv7511->cec_clk); i2c_unregister_device(adv7511->i2c_packet); i2c_unregister_device(adv7511->i2c_edid);