From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Fan Wu <fanwu01@zju.edu.cn>
Cc: <lucas.demarchi@intel.com>, <thomas.hellstrom@linux.intel.com>,
<airlied@gmail.com>, <simona@ffwll.ch>,
<intel-xe@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] drm/xe/i2c: cancel the client work on remove
Date: Thu, 10 Sep 2026 18:23:50 -0400 [thread overview]
Message-ID: <aqMt9p4QAaHUt1ov@intel.com> (raw)
In-Reply-To: <20260909052328.654682-1-fanwu01@zju.edu.cn>
On Wed, Sep 09, 2026 at 05:23:28AM +0000, Fan Wu wrote:
> xe_i2c_notifier() stores the DesignWare adapter in i2c->adapter and
> schedules i2c->work when the adapter is registered under the xe I2C
> platform device, and xe_i2c_client_work() then instantiates the AMC
> client device on that adapter.
>
> xe_i2c_remove() unregisters the client devices, the bus notifier and
> the adapter platform device, but it never drains i2c->work. A work
> item that is still queued or running when the adapter is unregistered
> dereferences i2c->adapter in i2c_new_client_device() after
> platform_device_unregister() has released the adapter. The work item
> is also embedded in the devm-allocated struct xe_i2c, so a work item
> still queued after the drm device devm unwind frees that allocation
> runs its callback on freed memory.
>
> Cancel the work in xe_i2c_remove(), after bus_unregister_notifier()
> so that no new instance can be scheduled, and before the adapter is
> unregistered so that a running instance still finds a live adapter.
>
> This issue was found by an in-house static analysis tool.
>
> Fixes: f0e53aadd702 ("drm/xe: Support for I2C attached MCUs")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5.6
> Co-developed-by: Song Li <songl@zju.edu.cn>
> Signed-off-by: Song Li <songl@zju.edu.cn>
> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
> ---
> drivers/gpu/drm/xe/xe_i2c.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
> index 706783863d07..5a176d78193b 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.c
> +++ b/drivers/gpu/drm/xe/xe_i2c.c
> @@ -311,6 +311,7 @@ static void xe_i2c_remove(void *data)
> i2c_unregister_device(i2c->client[i]);
>
> bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier);
> + cancel_work_sync(&i2c->work);
> xe_i2c_unregister_adapter(i2c);
> xe_i2c_remove_irq(i2c);
This code has changed. Could you please rebase on top of drm-tip?
Then recheck your solution. You might need something different...
> }
>
prev parent reply other threads:[~2026-09-10 22:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 5:23 Fan Wu
2026-09-10 22:23 ` Rodrigo Vivi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aqMt9p4QAaHUt1ov@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fanwu01@zju.edu.cn \
--cc=intel-xe@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®