FAILED: patch "[PATCH] drm/xe/i2c: cancel the client work on remove" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 611857adc9e7b0ee1239a0baf38498922ca5a12e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026101217-clumsily-geology-fe31@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 611857adc9e7b0ee1239a0baf38498922ca5a12e Mon Sep 17 00:00:00 2001
From: Fan Wu <[email protected]>
Date: Mon, 5 Oct 2026 20:04:14 -0400
Subject: [PATCH] drm/xe/i2c: cancel the client work on remove
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() tears down the AMC, 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.
The bus notifier is the only thing that schedules this work, and it is unregistered after the client devices. An instance that is still queued when the teardown runs can therefore write i2c->client[XE_I2C_CLIENT_AMC] while the loop is unregistering and clearing the same array, and an AMC client it instantiates late is only cleaned up by the adapter's own child sweep in i2c_del_adapter().
Move bus_unregister_notifier() in front of the client teardown loop and cancel the work right after it, so no new instance can be scheduled and a queued instance is drained before the client array is touched. A running instance still finds a live adapter, since the adapter is unregistered later.
drivers/gpu/drm/xe/xe_i2c.c +4 -1
@@ -324,12 +324,15 @@ static void xe_i2c_remove(void *data)xe_i2c_irq_reset (xe);xe_amc_exit (i2c); +/* Stop the notifier from arming the client work before teardown. */ +bus_unregister_notifier (&i2c_bus_type, &i2c->bus_notifier); +cancel_work_sync (&i2c->work); +for (i =0 ; i <XE_I2C_MAX_CLIENTS ; i++) {i2c_unregister_device (i2c->client[i]); i2c->client[i] =NULL ; } -bus_unregister_notifier (&i2c_bus_type, &i2c->bus_notifier);xe_i2c_unregister_adapter (i2c); xe->i2c =NULL ; }
Sasha Levin
maintainerPATCH 1/1 drm/xe/i2c: cancel the client work on remove
From: Fan Wu <[email protected]>
[ Upstream commit 611857adc9e7b0ee1239a0baf38498922ca5a12e ]
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() tears down the AMC, 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.
The bus notifier is the only thing that schedules this work, and it is unregistered after the client devices. An instance that is still queued when the teardown runs can therefore write i2c->client[XE_I2C_CLIENT_AMC] while the loop is unregistering and clearing the same array, and an AMC client it instantiates late is only cleaned up by the adapter's own child sweep in i2c_del_adapter().
Move bus_unregister_notifier() in front of the client teardown loop and cancel the work right after it, so no new instance can be scheduled and a queued instance is drained before the client array is touched. A running instance still finds a live adapter, since the adapter is unregistered later.
--- drivers/gpu/drm/xe/xe_i2c.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_i2c.c +4 -1
@@ -330,10 +330,13 @@ static void xe_i2c_remove(void *data)struct xe_i2c *i2c = data;unsigned int i; +/* Stop the notifier from arming the client work before teardown. */ +bus_unregister_notifier (&i2c_bus_type, &i2c->bus_notifier); +cancel_work_sync (&i2c->work); +for (i =0 ; i <XE_I2C_MAX_CLIENTS ; i++)i2c_unregister_device (i2c->client[i]); -bus_unregister_notifier (&i2c_bus_type, &i2c->bus_notifier);xe_i2c_unregister_adapter (i2c);xe_i2c_remove_irq (i2c); }
Signature · 1 line
2.53.0