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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4024C6FD19 for ; Thu, 16 Mar 2023 16:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbjCPQGv (ORCPT ); Thu, 16 Mar 2023 12:06:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjCPQGt (ORCPT ); Thu, 16 Mar 2023 12:06:49 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08F27A7A9B for ; Thu, 16 Mar 2023 09:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=BpTc3 Eb2o/NHHOlitSSzCEg5Jn4GYMsWpzIaxLSPuA8=; b=WNSp/H78L+tWzguIm83oX mBX4Bxg10MzcV/0giyIZdPlwvlVRNYPG8Fm7vfAEdE3T/9vGAzRLjdB/QCZgf/OV 9ESXfJOvA/OTTl0e8QJE9JaHjHYNiKy74MX4wlkdvD6sWjFNB2nFSRT902t4DVCg pIaD1jYHI0/IHcWxSHxvlk= Received: from leanderwang-LC2.localdomain (unknown [111.206.145.21]) by zwqz-smtp-mta-g3-3 (Coremail) with SMTP id _____wBnKqD0PRNkKSvSAA--.48535S2; Fri, 17 Mar 2023 00:04:04 +0800 (CST) From: Zheng Wang To: dri-devel@lists.freedesktop.org Cc: andrzej.hajda@intel.com, neil.armstrong@linaro.org, jonas@kwiboo.se, airlied@gmail.com, daniel@ffwll.ch, linux-kernel@vger.kernel.org, hackerzheng666@gmail.com, 1395428693sheep@gmail.com, alex000young@gmail.com, Zheng Wang Subject: [PATCH v2] drm/bridge: adv7511: fix race condition bug in adv7511_remove due to unfinished work Date: Fri, 17 Mar 2023 00:04:02 +0800 Message-Id: <20230316160402.1566483-1-zyytlz.wz@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wBnKqD0PRNkKSvSAA--.48535S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtr18Xr4rGw4ktrW3Ww1UGFg_yoWkCFXEkF yfZ34xWr15A3Wv9w17AFZFvrW7K3WUCrZa93WfKa9xJr43Zr1xW347XryDXF1ruF4YyFyD JrnrZw4rAa42kjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRKYFCUUUUUU== X-Originating-IP: [111.206.145.21] X-CM-SenderInfo: h2113zf2oz6qqrwthudrp/1tbiXRo0U1WBo8MtCQAAsw Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In adv7511_probe, adv7511->hpd_work is bound with adv7511_hpd_work. If we call adv7511_remove with a unfinished work. There may be a race condition where bridge->hpd_mutex was destroyed by drm_bridge_remove and used in adv7511_hpd_work in drm_bridge_hpd_notify. Fix it by canceling the work before cleanup in adv7511_remove. Fixes: 518cb7057a59 ("drm/bridge: adv7511: Use work_struct to defer hotplug handing to out of irq context") Signed-off-by: Zheng Wang --- drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index ddceafa7b637..9bf72dd6c1d3 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -1349,6 +1349,7 @@ static void adv7511_remove(struct i2c_client *i2c) { struct adv7511 *adv7511 = i2c_get_clientdata(i2c); + cancel_work_sync(&adv7511->hpd_work); adv7511_uninit_regulators(adv7511); drm_bridge_remove(&adv7511->bridge); -- 2.25.1